Skip to content
This repository has been archived by the owner on Jan 31, 2020. It is now read-only.

Commit

Permalink
Last commit should go to a branch.
Browse files Browse the repository at this point in the history
This reverts commit b98b8151d39d71db5d6b591df76acbabbc237579.
  • Loading branch information
Thinkscape committed Aug 22, 2011
1 parent 145b973 commit 51c4ced
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions src/SessionManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,14 @@ public function sessionExists()
/**
* Start session
*
* if No sesion currently exists, attempt to start it. Calls
* {@link isValid()} once session_start() is called, and raises an
* if No sesion currently exists, attempt to start it. Calls
* {@link isValid()} once session_start() is called, and raises an
* exception if validation fails.
*
* @param bool $preserveStorage If set to true, current session storage will not be overwritten by the
* contents of $_SESSION.
*
* @return void
* @throws Exception
*/
public function start($preserveStorage = false)
public function start()
{
if ($this->sessionExists()) {
return;
Expand All @@ -109,9 +107,7 @@ public function start($preserveStorage = false)
if ($storage instanceof Storage\SessionStorage
&& $_SESSION !== $storage
) {
if(!$preserveStorage){
$storage->fromArray($_SESSION);
}
$storage->fromArray($_SESSION);
$_SESSION = $storage;
}
}
Expand Down Expand Up @@ -261,7 +257,9 @@ public function regenerateId()
session_regenerate_id();
return $this;
}
$this->destroy();
session_regenerate_id();
$this->start();
return $this;
}

Expand Down Expand Up @@ -386,12 +384,19 @@ protected function _setSessionCookieLifetime($ttl)
return;
}

// Set new cookie TTL
$config->setCookieLifetime($ttl);

if ($this->sessionExists()) {
// There is a running session so we'll regenerate id to send a new cookie
$this->destroy(array('send_expire_cookie' => false));

// Since a cookie was destroyed, we should regenerate the ID
$this->regenerateId();
}

// Now simply set the cookie TTL
$config->setCookieLifetime($ttl);

if (!$this->sessionExists()) {
// Restart session if necessary
$this->start();
}
}
}

0 comments on commit 51c4ced

Please sign in to comment.