public function initializeUserSession(WebRequest $request, Response $response, User $user)
    {
        // If the session already has user data ...
        if ($request->getSessionData('userUuid') !== false) {
            $sessionToken = $request->getSessionData('userSessionToken');
            $sessionTokenLifetime = $request->getSessionData('userSessionTokenLifetime');
            
            // Cleanup the session
            $this->cleanupSession($request);
            
            // Save the old session token for some requests in the next 60 seconds
            if ($sessionToken !== false) {
                $request->setSessionData('oldUserSessionToken', $sessionToken);
                $request->setSessionData('oldUserSessionTokenLifetime', $sessionTokenLifetime);
            }
        }
        
        // Regenerate the session
        $this->regenerateSession($request);
        
        $sessionToken = md5($user->getUuid()) . '-' . md5(uniqid());
        $sessionTokenLifeTime = time() + 300;
        
        $request->setSessionData('userUuid', $user->getUuid());
        $request->setSessionData('userSessionToken', $sessionToken);
        $request->setSessionData('userSessionTokenLifetime', $sessionTokenLifeTime);

        setcookie($sessionToken, $sessionTokenLifeTime, 0, '/', '', $request->isSsl());
    }
public function initializeUserSession(WebRequest $request, Response $response, User $user)
    {
        // If the session already has user data ...
        if ($request->getSessionData('userUuid') !== false) {
            $sessionToken = $request->getSessionData('userSessionToken');
            $sessionTokenLifetime = $request->getSessionData('userSessionTokenLifetime');
            
            // Cleanup the session
            $this->cleanupSession($request);
            
            // Save the old session token for some requests in the next 60 seconds
            if ($sessionToken !== false) {
                $request->setSessionData('oldUserSessionToken', $sessionToken);
                $request->setSessionData('oldUserSessionTokenLifetime', $sessionTokenLifetime);
            }
        }
        
        // Regenerate the session
        $this->regenerateSession($request);
        
        $sessionToken = md5($user->getUuid()) . '-' . md5(uniqid());
        $sessionTokenLifeTime = time() + 300;
        
        $request->setSessionData('userUuid', $user->getUuid());
        $request->setSessionData('userSessionToken', $sessionToken);
        $request->setSessionData('userSessionTokenLifetime', $sessionTokenLifeTime);

        setcookie($sessionToken, $sessionTokenLifeTime, 0, '/', '', $request->isSsl());
    }
public function initializeUserSession ( WebRequest $ request , Response $ response , User $ user ) { // If the session already has user data ... if ( $ request -> getSessionData ( 'userUuid' ) !== false ) { $ sessionToken = $ request -> getSessionData ( 'userSessionToken' ) ; $ sessionTokenLifetime = $ request -> getSessionData ( 'userSessionTokenLifetime' ) ; // Cleanup the session $ this -> cleanupSession ( $ request ) ; // Save the old session token for some requests in the next 60 seconds if ( $ sessionToken !== false ) { $ request -> setSessionData ( 'oldUserSessionToken' , $ sessionToken ) ; $ request -> setSessionData ( 'oldUserSessionTokenLifetime' , $ sessionTokenLifetime ) ; } } // Regenerate the session $ this -> regenerateSession ( $ request ) ; $ sessionToken = md5 ( $ user -> getUuid ( ) ) . '-' . md5 ( uniqid ( ) ) ; $ sessionTokenLifeTime = time ( ) + 300 ; $ request -> setSessionData ( 'userUuid' , $ user -> getUuid ( ) ) ; $ request -> setSessionData ( 'userSessionToken' , $ sessionToken ) ; $ request -> setSessionData ( 'userSessionTokenLifetime' , $ sessionTokenLifeTime ) ; setcookie ( $ sessionToken , $ sessionTokenLifeTime , 0 , '/' , '' , $ request -> isSsl ( ) ) ; }
Initializes the user session

@access public
@param \Zepi\Turbo\Request\WebRequest $request
@param \Zepi\Turbo\Response\Response $response
@param \Zepi\Web\AccessControl\Entity\User $user
Initializes the user session