Fixed a bug in session middleware.