src/Webiny/Login/Login.php
private function storeUserSession($session)
    {
        // get all sessions
        $sessions = $this->getMeta()->sessions->val();
        if (!is_array($sessions)) {
            $sessions = [];
        }

        // delete the old sessions
        $newSessions = [];
        $ttl = $this->getSessionTtl();
        foreach ($sessions as $s) {
            if (($s['created'] + $ttl) > time()) {
                $newSessions[] = $s;
            }
        }

        // append the new session
        $newSessions[] = ['sid' => $session, 'created' => time(), 'ip' => $this->ip];

        // update the last login date
        $this->getMeta()->lastLogin = time();

        // append a new login attempt
        $this->getMeta()->loginAttempts[] = ['ip' => $this->ip, 'timestamp' => time()];

        // update the entity
        $this->getMeta()->sessions = $newSessions;
        $this->getMeta()->save();
    }
private function storeUserSession($session)
    {
        // get all sessions
        $sessions = $this->getMeta()->sessions->val();
        if (!is_array($sessions)) {
            $sessions = [];
        }

        // delete the old sessions
        $newSessions = [];
        $ttl = $this->getSessionTtl();
        foreach ($sessions as $s) {
            if (($s['created'] + $ttl) > time()) {
                $newSessions[] = $s;
            }
        }

        // append the new session
        $newSessions[] = ['sid' => $session, 'created' => time(), 'ip' => $this->ip];

        // update the last login date
        $this->getMeta()->lastLogin = time();

        // append a new login attempt
        $this->getMeta()->loginAttempts[] = ['ip' => $this->ip, 'timestamp' => time()];

        // update the entity
        $this->getMeta()->sessions = $newSessions;
        $this->getMeta()->save();
    }
private function storeUserSession ( $ session ) { // get all sessions $ sessions = $ this -> getMeta ( ) -> sessions -> val ( ) ; if ( ! is_array ( $ sessions ) ) { $ sessions = [ ] ; } // delete the old sessions $ newSessions = [ ] ; $ ttl = $ this -> getSessionTtl ( ) ; foreach ( $ sessions as $ s ) { if ( ( $ s [ 'created' ] + $ ttl ) > time ( ) ) { $ newSessions [ ] = $ s ; } } // append the new session $ newSessions [ ] = [ 'sid' => $ session , 'created' => time ( ) , 'ip' => $ this -> ip ] ; // update the last login date $ this -> getMeta ( ) -> lastLogin = time ( ) ; // append a new login attempt $ this -> getMeta ( ) -> loginAttempts [ ] = [ 'ip' => $ this -> ip , 'timestamp' => time ( ) ] ; // update the entity $ this -> getMeta ( ) -> sessions = $ newSessions ; $ this -> getMeta ( ) -> save ( ) ; }
Stores a new active session for the current user.

@param string $session

@throws LoginException
Stores a new active session for the current user .