added cookie storage limit exception.

This commit is contained in:
Taylor Otwell
2012-01-25 09:01:15 -06:00
parent 974ff302ef
commit c847bc4d5e

View File

@@ -23,9 +23,7 @@ class Cookie implements Driver {
{ {
if (\Laravel\Cookie::has(Cookie::payload)) if (\Laravel\Cookie::has(Cookie::payload))
{ {
$cookie = Crypter::decrypt(\Laravel\Cookie::get(Cookie::payload)); return unserialize(Crypter::decrypt(\Laravel\Cookie::get(Cookie::payload)));
return unserialize($cookie);
} }
} }
@@ -43,6 +41,14 @@ class Cookie implements Driver {
$payload = Crypter::encrypt(serialize($session)); $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); \Laravel\Cookie::put(Cookie::payload, $payload, $lifetime, $path, $domain);
} }