public function SessionProxy_Backend_Default::regenerate in Session Proxy 7
Regenerate the current session.
Overrides SessionProxy_Backend_Interface::regenerate
File
- lib/
SessionProxy/ Backend/ Default.php, line 74
Class
- SessionProxy_Backend_Default
- Default implementation relies on a custom storage engine.
Code
public function regenerate() {
global $user;
// FIXME: Default backend will erase current user at session read time.
// We need to get it out of there for good and avoid this ugly hack.
if ($user->uid) {
$account = $user;
}
if (!$this
->sessionIsEmpty()) {
$currentData = $_SESSION;
}
if ($this->started) {
$this
->destroy();
}
$this
->generateSessionIdentifier();
if (isset($currentData) && !empty($currentData)) {
$_SESSION = $currentData;
}
$this
->start();
// See comment above.
if (isset($account)) {
$user = $account;
}
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']);
}
// On session regenerate, the storage UID is set to the one read during
// the first session read attempt: we need to advertise the backend that
// future session write will be linked to a new UID.
$this->storage
->setSessionUid($user->uid);
$this
->refreshAfterSessionChange();
}