refactoring session handling.
This commit is contained in:
parent
c9beefaa28
commit
b7b5451a7f
|
@ -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'; }
|
class Session extends Facade { public static $resolve = 'laravel.session'; }
|
|
@ -21,13 +21,6 @@ class Manager {
|
||||||
*/
|
*/
|
||||||
private $transporter;
|
private $transporter;
|
||||||
|
|
||||||
/**
|
|
||||||
* The session payload instance.
|
|
||||||
*
|
|
||||||
* @var Payload
|
|
||||||
*/
|
|
||||||
private $payload;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates if the session exists in persistent storage.
|
* 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
|
// 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
|
// 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.
|
// 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;
|
$this->exists = false;
|
||||||
|
|
||||||
|
@ -82,19 +75,6 @@ public function payload($config)
|
||||||
return $payload;
|
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.
|
* 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
|
// 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.
|
// that the session will need to be persisted to the data store as a new session.
|
||||||
if ($payload->regenerated)
|
if ($payload->regenerated) $this->exists = false;
|
||||||
{
|
|
||||||
$this->exists = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($flash as $key => $value)
|
foreach ($flash as $key => $value)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue