diff --git a/application/config/session.php b/application/config/session.php index 2da93353..12ccb6ff 100644 --- a/application/config/session.php +++ b/application/config/session.php @@ -12,7 +12,7 @@ | Since HTTP is stateless, sessions are used to maintain "state" across | multiple requests from the same user of your application. | - | Supported Drivers: 'file', 'db', 'memcached', 'apc'. + | Supported Drivers: 'cookie', 'file', 'db', 'memcached', 'apc'. | */ diff --git a/system/session.php b/system/session.php index 63000e35..c57d6d97 100644 --- a/system/session.php +++ b/system/session.php @@ -27,6 +27,10 @@ public static function driver() { switch (Config::get('session.driver')) { + case 'cookie': + static::$driver = new Session\Cookie; + break; + case 'file': static::$driver = new Session\File; break; @@ -203,8 +207,8 @@ public static function close() Cookie::put('laravel_session', static::$session['id'], $minutes, $config['path'], $config['domain'], $config['https'], $config['http_only']); } - // 2% chance of performing session garbage collection... - if (mt_rand(1, 100) <= 2) + // 2% chance of performing session garbage collection on any given request... + if (mt_rand(1, 100) <= 2 and static::driver() instanceof Session\Sweeper) { static::driver()->sweep(time() - ($config['lifetime'] * 60)); } diff --git a/system/session/apc.php b/system/session/apc.php index 3716b5e4..7b236ba9 100644 --- a/system/session/apc.php +++ b/system/session/apc.php @@ -37,15 +37,4 @@ public function delete($id) Cache::driver('apc')->forget($id); } - /** - * Delete all expired sessions. - * - * @param int $expiration - * @return void - */ - public function sweep($expiration) - { - // APC sessions will expire automatically. - } - } \ No newline at end of file diff --git a/system/session/cookie.php b/system/session/cookie.php new file mode 100644 index 00000000..477b1f1f --- /dev/null +++ b/system/session/cookie.php @@ -0,0 +1,54 @@ +forget($id); } - /** - * Delete all expired sessions. - * - * @param int $expiration - * @return void - */ - public function sweep($expiration) - { - // Memcached sessions will expire automatically. - } - } \ No newline at end of file diff --git a/system/session/sweeper.php b/system/session/sweeper.php new file mode 100644 index 00000000..187ac414 --- /dev/null +++ b/system/session/sweeper.php @@ -0,0 +1,13 @@ +