public function SessionProxy_Backend_Native::regenerate in Session Proxy 7
Regenerate the current session.
Overrides SessionProxy_Backend_Interface::regenerate
File
- lib/
SessionProxy/ Backend/ Native.php, line 23
Class
- SessionProxy_Backend_Native
- Native implementation of session backend: use PHP native session handling. Using it allows to use built-in extensions session handling, such as Redis or Memcache extensions features, which are known to be really fast.
Code
public function regenerate() {
global $user;
if (!$this
->sessionIsEmpty()) {
$currentData = $_SESSION;
}
if ($this->started) {
$this
->destroy();
}
$this
->generateSessionIdentifier();
if (isset($currentData) && !empty($currentData)) {
$_SESSION = $currentData;
$this
->start();
if ($user->uid) {
$_SESSION['uid'] = $user->uid;
}
}
else {
if ($user->uid) {
$this
->start();
$_SESSION['uid'] = $user->uid;
}
}
if ($this->started) {
// Some PHP versions won't reset correctly the cookie.
$params = session_get_cookie_params();
$expire = $params['lifetime'] ? REQUEST_TIME + $params['lifetime'] : 0;
setcookie($this->sessionName, $this->sessionIdentifier, $expire, $params['path'], $params['domain'], $params['secure'], $params['httponly']);
}
$this
->refreshAfterSessionChange();
}