Regenerate session id

@param bool $updateBackendData (true if we want to keep session data with the new session id)
@return bool
426397
public function regenerate( $updateBackendData = true )
    {
        $oldSessionId = session_id();
        session_regenerate_id();
        $newSessionId = session_id();

        ezpEvent::getInstance()->notify( 'session/regenerate', array( $oldSessionId, $newSessionId ) );

        if ( $updateBackendData )
        {
            $db = eZDB::instance();
            if ( !$db->isConnected() )
            {
                return false;
            }

            $escOldKey = $db->escapeString( $oldSessionId );
            $escNewKey = $db->escapeString( $newSessionId );
            $escUserID = $db->escapeString( eZSession::userID() );
            eZSession::triggerCallback( 'regenerate_pre', array( $db, $escNewKey, $escOldKey, $escUserID ) );

            $db->query( "UPDATE ezsession SET session_key='$escNewKey', user_id='$escUserID' WHERE session_key='$escOldKey'" );
            $db->query( "UPDATE ezbasket SET session_id='$escNewKey' WHERE session_id='$escOldKey'" );

            eZSession::triggerCallback( 'regenerate_post', array( $db, $escNewKey, $escOldKey, $escUserID ) );
        }
        return true;
    }
1066288
protected function getUpdateEvent($formData)
    {
        $event = new HookUpdateEvent($formData['id']);

        return $this->hydrateEvent($event, $formData, true);
    }
135783
public function write($sessionId, $sessionData)
    {
        if ($this->_lock === false) {
            return $this->_fail();
        }

        $insertData = array(
            'id' => $sessionId,
            'ip_address' => $_SERVER['REMOTE_ADDR'],
            'timestamp' => time(),
            'data' => $sessionData
        );

        if (!$this->row_exists) {
            if ($this->newQuery()->insert($insertData)) {
                $this->_session_id = $sessionId;
                $this->row_exists = true;
                $this->_fingerprint = md5($sessionData);
                return $this->_success;
            }
        } else {
            if ($this->newQuery()->where('id', $this->_session_id)->update($insertData)) {
                $this->_session_id = $sessionId;
                $this->row_exists = true;
                $this->_fingerprint = md5($sessionData);
                return $this->_success;
            }
        }
        return $this->_fail();
    }
1093290
public function update_instance($formdata) {
        global $DB;
        $adminconfig = $this->get_admin_config();

        $update = new stdClass();
        $update->id = $formdata->instance;
        $update->name = $formdata->name;
        $update->timemodified = time();
        $update->course = $formdata->course;
        $update->intro = $formdata->intro;
        $update->introformat = $formdata->introformat;
        $update->alwaysshowdescription = !empty($formdata->alwaysshowdescription);
        $update->submissiondrafts = $formdata->submissiondrafts;
        $update->requiresubmissionstatement = $formdata->requiresubmissionstatement;
        $update->sendnotifications = $formdata->sendnotifications;
        $update->sendlatenotifications = $formdata->sendlatenotifications;
        $update->sendstudentnotifications = $adminconfig->sendstudentnotifications;
        if (isset($formdata->sendstudentnotifications)) {
            $update->sendstudentnotifications = $formdata->sendstudentnotifications;
        }
        $update->duedate = $formdata->duedate;
        $update->cutoffdate = $formdata->cutoffdate;
        $update->gradingduedate = $formdata->gradingduedate;
        $update->allowsubmissionsfromdate = $formdata->allowsubmissionsfromdate;
        $update->grade = $formdata->grade;
        if (!empty($formdata->completionunlocked)) {
            $update->completionsubmit = !empty($formdata->completionsubmit);
        }
        $update->teamsubmission = $formdata->teamsubmission;
        $update->requireallteammemberssubmit = $formdata->requireallteammemberssubmit;
        if (isset($formdata->teamsubmissiongroupingid)) {
            $update->teamsubmissiongroupingid = $formdata->teamsubmissiongroupingid;
        }
        if (isset($formdata->hidegrader)) {
            $update->hidegrader = $formdata->hidegrader;
        }
        $update->blindmarking = $formdata->blindmarking;
        $update->attemptreopenmethod = ASSIGN_ATTEMPT_REOPEN_METHOD_NONE;
        if (!empty($formdata->attemptreopenmethod)) {
            $update->attemptreopenmethod = $formdata->attemptreopenmethod;
        }
        if (!empty($formdata->maxattempts)) {
            $update->maxattempts = $formdata->maxattempts;
        }
        if (isset($formdata->preventsubmissionnotingroup)) {
            $update->preventsubmissionnotingroup = $formdata->preventsubmissionnotingroup;
        }
        $update->markingworkflow = $formdata->markingworkflow;
        $update->markingallocation = $formdata->markingallocation;
        if (empty($update->markingworkflow)) { // If marking workflow is disabled, make sure allocation is disabled.
            $update->markingallocation = 0;
        }

        $result = $DB->update_record('assign', $update);
        $this->instance = $DB->get_record('assign', array('id'=>$update->id), '*', MUST_EXIST);

        $this->save_intro_draft_files($formdata);

        // Load the assignment so the plugins have access to it.

        // Call save_settings hook for submission plugins.
        foreach ($this->submissionplugins as $plugin) {
            if (!$this->update_plugin_instance($plugin, $formdata)) {
                print_error($plugin->get_error());
                return false;
            }
        }
        foreach ($this->feedbackplugins as $plugin) {
            if (!$this->update_plugin_instance($plugin, $formdata)) {
                print_error($plugin->get_error());
                return false;
            }
        }

        $this->update_calendar($this->get_course_module()->id);
        $completionexpected = (!empty($formdata->completionexpected)) ? $formdata->completionexpected : null;
        \core_completion\api::update_completion_date_event($this->get_course_module()->id, 'assign', $this->instance,
                $completionexpected);
        $this->update_gradebook(false, $this->get_course_module()->id);

        $update = new stdClass();
        $update->id = $this->get_instance()->id;
        $update->nosubmissions = (!$this->is_any_submission_plugin_enabled()) ? 1: 0;
        $DB->update_record('assign', $update);

        return $result;
    }
262421
public function update($update, $session, $sessionId)
    {

        $database = $this->database;
        if (isset($update["session_registry"])) {
            $update["session_registry"] = $database->quote($update["session_registry"]);
        }

        //now update the session;
        $database->update($session->table, $update, array("session_key" => $database->quote($sessionId)));

        return true;
    }
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();
    }
1055821
public void remoteInvalidate(String sessionId, boolean backendUpdate) {
        // backendUpdate not used here...there is no backend for in-memory
        if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled() && LoggingUtil.SESSION_LOGGER_CORE.isLoggable(Level.FINE)) {
            StringBuffer sb = new StringBuffer("{").append(sessionId).append(",").append(backendUpdate).append("} ").append(appNameForLogging);
            LoggingUtil.SESSION_LOGGER_CORE.logp(Level.FINE, methodClassName, methodNames[REMOVE_INVALIDATE], sb.toString());
        }
        ISession iSess = (ISession) _sessions.get(sessionId);
        if (iSess != null) {
            iSess.setMaxInactiveInterval(0); // let invalidator whack it
        }
    }
265559
public function regenerateID(bool $destroy = false){
        if($this->status() !== self::ACTIVE){
            throw Exception\SessionException::notStarted();
        }else if(!session_regenerate_id($destroy)){
            throw Exception\SessionException::canNotRegenerateID();
        }

        return $this;
    }
124349
public function regenerate()
    {
        // we will regenerate session ID
        session_regenerate_id(true);

        session_write_close();

        if (isset($_SESSION)) {
            $data = $_SESSION;
            session_start();
            $_SESSION = $data;
        } else {
            session_start();
        }

        // we will store session global variable reference into storage property
        $this->storage = &$_SESSION;

        return $this;
    }
907969
public function regenerateSessionId()
    {
        // starting session only if it was not started yet
        if (self::$_blIsNewSession) {
            $this->_sessionStart();

            // (re)setting actual user agent when initiating new session
            $this->setVariable("sessionagent", \OxidEsales\Eshop\Core\Registry::getUtilsServer()->getServerVar('HTTP_USER_AGENT'));
        }

        $this->_setSessionId($this->_getNewSessionId(false));
        $this->_initNewSessionChallenge();
    }
1258372
async function refreshSession (ctx, session, originalHash, isNew) {

    // reject any session changes, and do not update session expiry
    if(ctx._sessionSave === false) {
      return debug('session save disabled')
    }

    //delete session
    if (!session) {
      if (!isNew) {
        debug('session set to null, destroy session: %s', ctx.sessionId)
        sessionIdStore.reset.call(ctx)
        return store.destroy(ctx.sessionId)
      }
      return debug('a new session and set to null, ignore destroy')
    }

    // force saving non-empty session
    if(ctx._sessionSave === true) {
      debug('session save forced')
      return saveNow(ctx, ctx.sessionId, session)
    }

    const newHash = hash(session)
    // if new session and not modified, just ignore
    if (!options.allowEmpty && isNew && newHash === EMPTY_SESSION_HASH) {
      return debug('new session and do not modified')
    }

    // rolling session will always reset cookie and session
    if (!options.rolling && newHash === originalHash) {
      return debug('session not modified')
    }

    debug('session modified')

    await saveNow(ctx, ctx.sessionId, session)

  }
224547
public function update($itemData, $createIfAbsent = false)
    {
        $newData = $this->preUpdate($itemData, $createIfAbsent);
        $result = $this->dataStore->update($newData, $createIfAbsent);

        return $this->postUpdate($result, $newData, $createIfAbsent);
    }
496635
protected function doUpdate(array $entityData)
    {
        $user = $this->find($entityData['id']);

        return $this->populate($user, $entityData);
    }
724911
public void remoteInvalidate(String sessionId, boolean backendUpdate) {
        IStore iStore = _coreHttpSessionManager.getIStore();
        ((MemoryStore) iStore).remoteInvalidate(sessionId, backendUpdate);
    }
18121
public function regenerate_id($destroy=true)
    {
        session_regenerate_id($destroy);

        $this->vars = null;
        $this->key  = session_id();

        return true;
    }
902637
protected function setUserSessionBackup()
    {
        $this->userSessionBackup = isset($_SESSION[self::SESSION_PARAMETER_CLOUDCONTROL]) ? $_SESSION[self::SESSION_PARAMETER_CLOUDCONTROL] : null;
        $fakeUser = new \stdClass();
        $fakeUser->username = self::SESSION_PARAMETER_FORM_COMPONENT;
        $_SESSION[self::SESSION_PARAMETER_CLOUDCONTROL] = $fakeUser;
    }
266824
private function resetVisitorUuid($data = null)
    {
        $this->visitorInfo['uuid'] = null;

        $data = $data ?: $this->visitorInfo;

        unset($data['uuid']);

        $this->putSessionData($data);
        $this->checkVisitorUuid();

        return $data;
    }