added cookie storage limit exception.

This commit is contained in:
Taylor Otwell 2012-01-25 09:01:15 -06:00
parent 974ff302ef
commit c847bc4d5e
1 changed files with 9 additions and 3 deletions

View File

@ -23,9 +23,7 @@ public function load($id)
{
if (\Laravel\Cookie::has(Cookie::payload))
{
$cookie = Crypter::decrypt(\Laravel\Cookie::get(Cookie::payload));
return unserialize($cookie);
return unserialize(Crypter::decrypt(\Laravel\Cookie::get(Cookie::payload)));
}
}
@ -43,6 +41,14 @@ public function save($session, $config, $exists)
$payload = Crypter::encrypt(serialize($session));
// A cookie payload can't exceed 4096 bytes, so if the encrypted payload
// is greater than that, we'll throw an exception so the developer can
// switch to another session driver for the application.
if (strlen($payload) > 4000)
{
throw new \Exception("Session payload too large for cookie.");
}
\Laravel\Cookie::put(Cookie::payload, $payload, $lifetime, $path, $domain);
}