fix session related bugs.
This commit is contained in:
@@ -77,7 +77,7 @@ return array(
|
||||
|
||||
'laravel.session.cookie' => array('resolver' => function($container)
|
||||
{
|
||||
return new Session\Cookie(new Crypter, $container->resolve('laravel.request')->input->cookies);
|
||||
return new Session\Cookie(Security\Crypter::make(), $container->resolve('laravel.request')->input->cookies);
|
||||
}),
|
||||
|
||||
/*
|
||||
|
||||
@@ -113,21 +113,6 @@ require SYS_PATH.'routing/route'.EXT;
|
||||
require SYS_PATH.'routing/router'.EXT;
|
||||
require SYS_PATH.'routing/handler'.EXT;
|
||||
|
||||
// --------------------------------------------------------------
|
||||
// Load the session.
|
||||
// --------------------------------------------------------------
|
||||
if (Config::get('session.driver') != '') Session\Manager::driver()->start(Cookie::get('laravel_session'));
|
||||
|
||||
// --------------------------------------------------------------
|
||||
// Load the packages that are in the auto-loaded packages array.
|
||||
// --------------------------------------------------------------
|
||||
if (count(Config::get('application.packages')) > 0)
|
||||
{
|
||||
require SYS_PATH.'package'.EXT;
|
||||
|
||||
Package::load(Config::get('application.packages'));
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------
|
||||
// Initialize the request instance for the request.
|
||||
// --------------------------------------------------------------
|
||||
@@ -140,6 +125,24 @@ IoC::container()->instance('laravel.request', $request);
|
||||
// --------------------------------------------------------------
|
||||
$request->input = new Input($request->method(), $request->is_spoofed(), $_GET, $_POST, $_FILES, new Cookie($_COOKIE));
|
||||
|
||||
// --------------------------------------------------------------
|
||||
// Load the session.
|
||||
// --------------------------------------------------------------
|
||||
if (Config::get('session.driver') != '')
|
||||
{
|
||||
Session\Manager::driver()->start($request->input->cookies->get('laravel_session'));
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------
|
||||
// Load the packages that are in the auto-loaded packages array.
|
||||
// --------------------------------------------------------------
|
||||
if (count(Config::get('application.packages')) > 0)
|
||||
{
|
||||
require SYS_PATH.'package'.EXT;
|
||||
|
||||
Package::load(Config::get('application.packages'));
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------
|
||||
// Route the request and get the response from the route.
|
||||
// --------------------------------------------------------------
|
||||
@@ -161,7 +164,7 @@ if (Config::get('session.driver') != '')
|
||||
|
||||
$driver->flash('laravel_old_input', $request->input->get());
|
||||
|
||||
$driver->close();
|
||||
$driver->close($request->input->cookies);
|
||||
|
||||
if ($driver instanceof Session\Sweeper and mt_rand(1, 100) <= 2)
|
||||
{
|
||||
|
||||
@@ -23,10 +23,10 @@ class Cookie extends Driver {
|
||||
* Create a new Cookie session driver instance.
|
||||
*
|
||||
* @param Crypter $crypter
|
||||
* @param Cookie $cookie
|
||||
* @param Laravel\Cookie $cookie
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Crypter $crypter, Cookie $cookie)
|
||||
public function __construct(Crypter $crypter, \Laravel\Cookie $cookie)
|
||||
{
|
||||
$this->cookie = $cookie;
|
||||
$this->crypter = $crypter;
|
||||
|
||||
@@ -188,15 +188,16 @@ abstract class Driver {
|
||||
* The session will be stored in persistant storage and the session cookie will be
|
||||
* session cookie will be sent to the browser.
|
||||
*
|
||||
* @param Laravel\Cookie $cookie
|
||||
* @return void
|
||||
*/
|
||||
public function close()
|
||||
public function close(\Laravel\Cookie $cookie)
|
||||
{
|
||||
$this->age_flash();
|
||||
|
||||
$this->save();
|
||||
|
||||
$this->write_cookie();
|
||||
$this->write_cookie($cookie);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -225,15 +226,20 @@ abstract class Driver {
|
||||
/**
|
||||
* Write the session cookie.
|
||||
*
|
||||
* @param Laravel\Cookie $cookie
|
||||
* @return void
|
||||
*/
|
||||
protected function write_cookie()
|
||||
protected function write_cookie(\Laravel\Cookie $cookie)
|
||||
{
|
||||
if ( ! headers_sent())
|
||||
{
|
||||
$minutes = (Config::get('session.expire_on_close')) ? 0 : Config::get('session.lifetime');
|
||||
$config = Config::get('session');
|
||||
|
||||
Cookie::put('laravel_session', static::$session['id'], $minutes, Config::get('session.path'), Config::get('session.domain'), Config::get('session.https'), Config::get('http_only'));
|
||||
extract($config);
|
||||
|
||||
$minutes = ($expire_on_close) ? 0 : $lifetime;
|
||||
|
||||
$cookie->put('laravel_session', $this->session['id'], $minutes, $path, $domain, $https, $http_only);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?php namespace Laravel\Session;
|
||||
|
||||
use Laravel\IoC;
|
||||
use Laravel\Config;
|
||||
|
||||
class Manager {
|
||||
@@ -26,7 +27,7 @@ class Manager {
|
||||
{
|
||||
$driver = Config::get('session.driver');
|
||||
|
||||
if (in_array($driver, array('cookie', 'file', 'database', 'memcached')))
|
||||
if (in_array($driver, array('cookie', 'file', 'database', 'apc', 'memcached')))
|
||||
{
|
||||
return static::$driver = IoC::container()->resolve('laravel.session.'.$driver);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user