Commit ebd8bd55 by Taylor Otwell

added http_only option to cookie::put method.

parent d420d1c0
...@@ -33,11 +33,12 @@ class Cookie { ...@@ -33,11 +33,12 @@ class Cookie {
* @param string $path * @param string $path
* @param string $domain * @param string $domain
* @param bool $secure * @param bool $secure
* @param bool $http_only
* @return bool * @return bool
*/ */
public static function forever($name, $value, $path = '/', $domain = null, $secure = false) public static function forever($name, $value, $path = '/', $domain = null, $secure = false, $http_only = false)
{ {
return static::put($name, $value, 2628000, $path, $domain, $secure); return static::put($name, $value, 2628000, $path, $domain, $secure, $http_only);
} }
/** /**
...@@ -50,16 +51,17 @@ class Cookie { ...@@ -50,16 +51,17 @@ class Cookie {
* @param string $path * @param string $path
* @param string $domain * @param string $domain
* @param bool $secure * @param bool $secure
* @param bool $http_only
* @return bool * @return bool
*/ */
public static function put($name, $value, $minutes = 0, $path = '/', $domain = null, $secure = false) public static function put($name, $value, $minutes = 0, $path = '/', $domain = null, $secure = false, $http_only = false)
{ {
if ($minutes < 0) if ($minutes < 0)
{ {
unset($_COOKIE[$name]); unset($_COOKIE[$name]);
} }
return setcookie($name, $value, ($minutes != 0) ? time() + ($minutes * 60) : 0, $path, $domain, $secure); return setcookie($name, $value, ($minutes != 0) ? time() + ($minutes * 60) : 0, $path, $domain, $secure, $http_only);
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment