refactoring session handling.

This commit is contained in:
Taylor Otwell 2011-10-08 23:53:13 -05:00
parent c9beefaa28
commit b7b5451a7f
2 changed files with 2 additions and 27 deletions

View File

@ -32,6 +32,4 @@ public static function __callStatic($method, $parameters)
}
class Crypter extends Facade { public static $resolve = 'laravel.crypter'; }
class Hasher extends Facade { public static $resolve = 'laravel.hasher'; }
class Session extends Facade { public static $resolve = 'laravel.session'; }

View File

@ -21,13 +21,6 @@ class Manager {
*/
private $transporter;
/**
* The session payload instance.
*
* @var Payload
*/
private $payload;
/**
* Indicates if the session exists in persistent storage.
*
@ -61,7 +54,7 @@ public function payload($config)
// If the session is expired, a new session will be generated and all of the data from
// the previous session will be lost. The new session will be assigned a random, long
// string ID to uniquely identify it among the application's current users.
if (is_null($session) or $this->expired($session, $config))
if (is_null($session) or (time() - $session['last_activity']) > ($config['lifetime'] * 60))
{
$this->exists = false;
@ -82,19 +75,6 @@ public function payload($config)
return $payload;
}
/**
* Deteremine if the session is expired based on the last activity timestamp
* and the session lifetime set in the configuration file.
*
* @param array $session
* @param array $config
* @return bool
*/
private function expired($session, $config)
{
return (time() - $session['last_activity']) > ($config['lifetime'] * 60);
}
/**
* Close the session handling for the request.
*
@ -107,10 +87,7 @@ public function close(Payload $payload, $config, $flash = array())
{
// If the session ID has been regenerated, we will need to inform the session driver
// that the session will need to be persisted to the data store as a new session.
if ($payload->regenerated)
{
$this->exists = false;
}
if ($payload->regenerated) $this->exists = false;
foreach ($flash as $key => $value)
{