123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123 |
- <?php namespace Laravel;
- class Cookie {
-
- const forever = 525600;
-
- public static $jar = array();
-
- public static function has($name)
- {
- return ! is_null(static::get($name));
- }
-
- public static function get($name, $default = null)
- {
- if (isset(static::$jar[$name])) return static::$jar[$name]['value'];
- return array_get(Request::foundation()->cookies->all(), $name, $default);
- }
-
- public static function put($name, $value, $expiration = 0, $path = '/', $domain = null, $secure = false)
- {
- if ($expiration !== 0)
- {
- $expiration = time() + ($expiration * 60);
- }
-
-
-
- if ($secure and ! Request::secure())
- {
- throw new \Exception("Attempting to set secure cookie over HTTP.");
- }
- static::$jar[$name] = compact('name', 'value', 'expiration', 'path', 'domain', 'secure');
- }
-
- public static function forever($name, $value, $path = '/', $domain = null, $secure = false)
- {
- return static::put($name, $value, static::forever, $path, $domain, $secure);
- }
-
- public static function forget($name, $path = '/', $domain = null, $secure = false)
- {
- return static::put($name, null, -2000, $path, $domain, $secure);
- }
- }
|