protected function regenerateSession(WebRequest $request)
    {
        // Let the old session expire...
        $request->setSessionData('isObsolete', true);
        $request->setSessionData('maxLifetime', time() + 60);
        
        // Regenerate the session id but don't delete the old one
        session_regenerate_id(false);
        
        // Get the new session id
        $newSessionId = session_id();
        
        // Close both sessions to free them for other requests
        session_write_close();
        
        // Start the session with the new id
        session_id($newSessionId);
        session_start();
        
        // Delete the temporary session data
        $request->deleteSessionData('isObsolete');
        $request->deleteSessionData('maxLifetime');
    }