Refactored code attaching express session middleware.