Fixed bug in session middleware.