refactoring container for speed.
This commit is contained in:
@@ -4,37 +4,6 @@ use Laravel\Security\Crypter;
|
||||
|
||||
class Cookie implements Driver {
|
||||
|
||||
/**
|
||||
* The crypter instance.
|
||||
*
|
||||
* All session cookies have an encrypted payload. Since the session contains sensitive
|
||||
* data that cannot be compromised, it is important that the payload be encrypted using
|
||||
* the strong encryption provided by the Crypter class.
|
||||
*
|
||||
* @var Crypter
|
||||
*/
|
||||
private $crypter;
|
||||
|
||||
/**
|
||||
* The cookie manager instance.
|
||||
*
|
||||
* @var Cookie
|
||||
*/
|
||||
private $cookies;
|
||||
|
||||
/**
|
||||
* Create a new Cookie session driver instance.
|
||||
*
|
||||
* @param Crypter $crypter
|
||||
* @param Cookie $cookies
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Crypter $crypter, \Laravel\Cookie $cookies)
|
||||
{
|
||||
$this->crypter = $crypter;
|
||||
$this->cookies = $cookies;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load a session from storage by a given ID.
|
||||
*
|
||||
@@ -45,9 +14,9 @@ class Cookie implements Driver {
|
||||
*/
|
||||
public function load($id)
|
||||
{
|
||||
if ($this->cookies->has('session_payload'))
|
||||
if (\Laravel\Cookie::has('session_payload'))
|
||||
{
|
||||
return unserialize($this->crypter->decrypt($this->cookies->get('session_payload')));
|
||||
return unserialize(Crypter::decrypt(\Laravel\Cookie::get('session_payload')));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,9 +32,9 @@ class Cookie implements Driver {
|
||||
{
|
||||
extract($config);
|
||||
|
||||
$payload = $this->crypter->encrypt(serialize($session));
|
||||
$payload = Crypter::encrypt(serialize($session));
|
||||
|
||||
$this->cookies->put('session_payload', $payload, $lifetime, $path, $domain);
|
||||
\Laravel\Cookie::put('session_payload', $payload, $lifetime, $path, $domain);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -76,7 +45,7 @@ class Cookie implements Driver {
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
$this->cookies->forget('session_payload');
|
||||
\Laravel\Cookie::forget('session_payload');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,13 +2,6 @@
|
||||
|
||||
class Cookie implements Transporter {
|
||||
|
||||
/**
|
||||
* The cookie manager instance.
|
||||
*
|
||||
* @var Cookie
|
||||
*/
|
||||
protected $cookies;
|
||||
|
||||
/**
|
||||
* The name of the cookie used to store the session ID.
|
||||
*
|
||||
@@ -16,17 +9,6 @@ class Cookie implements Transporter {
|
||||
*/
|
||||
const key = 'laravel_session';
|
||||
|
||||
/**
|
||||
* Create a new cookie session transporter instance.
|
||||
*
|
||||
* @param Cookie $cookie
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(\Laravel\Cookie $cookies)
|
||||
{
|
||||
$this->cookies = $cookies;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the session identifier for the request.
|
||||
*
|
||||
@@ -35,7 +17,7 @@ class Cookie implements Transporter {
|
||||
*/
|
||||
public function get($config)
|
||||
{
|
||||
return $this->cookies->get(Cookie::key);
|
||||
return \Laravel\Cookie::get(Cookie::key);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -52,7 +34,7 @@ class Cookie implements Transporter {
|
||||
// deleted until the user closes their browser.
|
||||
$minutes = ( ! $config['expire_on_close']) ? $config['lifetime'] : 0;
|
||||
|
||||
$this->cookies->put(Cookie::key, $id, $minutes, $config['path'], $config['domain']);
|
||||
\Laravel\Cookie::put(Cookie::key, $id, $minutes, $config['path'], $config['domain']);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user