setup cookie based sessions and flash message middleware