Session management middleware for connect