Refactoring the session class.
This commit is contained in:
@@ -52,22 +52,18 @@ class Session {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load the session for the user.
|
* Load a user session by ID.
|
||||||
*
|
*
|
||||||
|
* @param string $id
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public static function load()
|
public static function load($id)
|
||||||
{
|
{
|
||||||
if ( ! is_null($id = Cookie::get('laravel_session')))
|
static::$session = ( ! is_null($id)) ? static::driver()->load($id) : null;
|
||||||
{
|
|
||||||
static::$session = static::driver()->load($id);
|
|
||||||
}
|
|
||||||
|
|
||||||
// If the session is invalid or expired, start a new one.
|
if (is_null(static::$session) or static::expired(static::$session['last_activity']))
|
||||||
if (is_null($id) or is_null(static::$session) or static::expired(static::$session['last_activity']))
|
|
||||||
{
|
{
|
||||||
static::$session['id'] = Str::random(40);
|
static::$session = array('id' => Str::random(40), 'data' => array());
|
||||||
static::$session['data'] = array();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! static::has('csrf_token'))
|
if ( ! static::has('csrf_token'))
|
||||||
|
|||||||
Reference in New Issue
Block a user