Regenerate id.

Regenerate the session ID, using session save handler's
native ID generation Can safely be called in the middle of a session.

@param bool $deleteOldSession

@return bool
977746
public function regenerateId(bool $deleteOldSession = true): bool
    {
        if ($this->isStarted()) {
            return session_regenerate_id($deleteOldSession);
        }
        // TODO : ajouter un else et lever une exception si on essaye de faire un regenerate ID alors que la session n'est pas démarrée !!!!

        return false;
    }
1233764
public function beforeDelete()
    {
        if (parent::beforeDelete() === false) {
            return false;
        }
        $storage = PropertyStorageHelper::storageById($this->storage_id);
        return $storage->beforePropertyDelete($this);
    }
195226
public function onDelete(Event\Delete $event)
    {
        $success = $event->getUser()->delete();
        $event->setResult( (bool)$success );
        if( $event->getResult() === false )
        {
            $event->stopPropagation(true);
        }
        return $event;
    }
449466
function _storage()
    {
        if (! $this->_session ) {
            // Store in session by realm defined with this authentication domain
            $session = new SessionStore(self::STORAGE_IDENTITY_KEY.'_'.$this->getRealm());
            $this->_session = $session;
        }

        return $this->_session;
    }
241476
public static function startSession(common_session_Session $session) {

        self::$session = $session;
        // do not start session in cli mode (testcase script)
        if(PHP_SAPI != 'cli'){
            if ($session instanceof common_session_StatefulSession) {
                
                // start session if not yet started
                if (session_id() === '') {
                    session_name(GENERIS_SESSION_NAME);
                    session_start();
                } else {
                    // prevent session fixation.
                    session_regenerate_id();
                }
                
                PHPSession::singleton()->setAttribute(self::PHPSESSION_SESSION_KEY, $session);
            }
        }
        return true;
    }
1119374
public function end(bool $deleteCookie = true): bool
    {
        if (!$this->ended) {
            $this->id = '';
            $this->ended = session_destroy();
            if ($this->ended) {
                $this->reset();
            }

            if ($deleteCookie) {
                setcookie($this->name, '', 0,
                    $this->cookieOptions['path'], $this->cookieOptions['domain'],
                    $this->cookieOptions['secure'], $this->cookieOptions['httponly']
                );
            }
        }

        return $this->ended;
    }
208868
public function clear():bool
    {
        if (true === $this->isStarted()) {
            session_unset();
            $this->setToDefault();
            session_regenerate_id(true);
            return (empty($_SESSION)? true : false);
        }
        throw new Server500(new \ArrayObject(array("explain" => "Cannot clear the session when is not started",
            "solution" => "Please start a session instance before clear it")));
    }
211616
private static function runIdRegeneration(int $interval = null, string $key = null)
    {
        if (empty($interval)) {
            return;
        }

        $expiry = time() + $interval;

        if (!isset($_SESSION[$key])) {
            $_SESSION[$key] = $expiry;
        }

        if ($_SESSION[$key] < time() || $_SESSION[$key] > $expiry) {
            session_regenerate_id(true);

            $_SESSION[$key] = $expiry;
        }
    }
1142414
public function resetSession()
    {
        /*
         * TODO not in love with suppressing errors
         */
        if (session_status() !== PHP_SESSION_ACTIVE) {
            @session_start();
        }
        @session_destroy();
        @session_unset();
        @session_start();
        session_regenerate_id(true);
        $_SESSION[__CLASS__] =& $this;
        session_write_close();
    }
957833
def delete(self):
        
        result = yield gen.Task(RedisSession._redis_client.delete, self._key)
        LOGGER.debug('Deleted session %s (%r)', self.id, result)
        self.clear()
        raise gen.Return(result)
1062018
public function deleteSession($user_id)
    {
        if (!isset($_SESSION['admin_sid'])) {
            return true;
        }
        $user_id = (int)$user_id;

        $sessions = new UsersSessionEntityRepository();
        $sessions->setWhereUserId($user_id);
        $sessions->setWhereSid($_SESSION['admin_sid']);
        $sessions->deleteObjectCollection();

        return true;
    }
640059
public function restoreSession($user_id = null)
    {
        if (empty($user_id)) {
            $user_id = activeUser('id');
        }

        if (empty($user_id)) {
            $this->setError('Must specify which user ID\'s session to restore.');
            return false;
        }

        $oUser = $this->oUserModel->getById($user_id);

        if (!$oUser) {
            $this->setError('Invalid User ID');
            return false;
        }

        // --------------------------------------------------------------------------

        //  Clean slate
        $this->oHybridAuth->logoutAllProviders();

        // --------------------------------------------------------------------------

        $this->oDb->where('user_id', $oUser->id);
        $aSessions = $this->oDb->get(NAILS_DB_PREFIX . 'user_social')->result();
        $aRestore  = [];

        foreach ($aSessions as $oSession) {
            $oSession->session_data = unserialize($oSession->session_data);
            $aRestore               = array_merge($aRestore, $oSession->session_data);
        }

        return $this->oHybridAuth->restoreSessionData(serialize($aRestore));
    }
249860
public function delete($request) {
		//get attendee from registration
		$attendee = $this->registration->Attendees()
			->byID($request->param('ID'));
		if(!$attendee) {
			return $this->httpError(404, "Attendee not found");
		}else if($this->canDelete()){
			$this->extend("onBeforeDelete", $attendee, $this->registration);
			$attendee->delete();
		}
		return $this->redirect($this->BackURL);
	}
936033
private function deleteSessionCookie() {
		$params = \session_get_cookie_params();

		// ask for the session cookie to be deleted (requests a cookie to be written on the client)
		$cookie = new Cookie(\session_name());
		$cookie->setPath($params['path']);
		$cookie->setDomain($params['domain']);
		$cookie->setHttpOnly($params['httponly']);
		$cookie->setSecureOnly($params['secure']);
		$result = $cookie->delete();

		if ($result === false) {
			throw new HeadersAlreadySentError();
		}
	}
1107456
public function regenerate()
    {
        // If headers already sent can't do much
        if (headers_sent()) {
            return;
        }
        
        // Clear old session data
        $_SESSION = [];
        // Set session start time
        $_SESSION['s3ss10nCr3at3d'] = time();
        // Set new session token
        if ($this->matchUserAgent) {
            $_SESSION['n3k0t'] = hash_hmac($this->hashAlgo, $_SERVER['HTTP_USER_AGENT'] . $_SESSION['s3ss10nCr3at3d'], $this->hashKey);
        } else {
            $_SESSION['n3k0t'] = hash_hmac($this->hashAlgo, $_SESSION['s3ss10nCr3at3d'], $this->hashKey);
        }
        // Regenerate session
        session_regenerate_id();
    }
1022340
public function regenerate($destroy = false, $lifetime = null)
    {
        if (!$this->isStarted()) {
            return false;
        }
        
        if (null !== $lifetime) {
            ini_set('session.cookie_lifetime', $lifetime);
        }
    
        \Wslim\Ioc::logger('session')->debug(sprintf('[%s]regenerate', static::getId()));
        
        return session_regenerate_id($destroy);
    }
870240
public function regenerate( $destroy = false ) {
		if ( $destroy ) {
			$this->handler->destroy( $this->get_id() );
		}

		$this->set_id( $this->generate_session_id() );

		return true;
	}