added http_only option to cookie::put method.
This commit is contained in:
parent
d420d1c07f
commit
ebd8bd55b2
|
@ -28,38 +28,40 @@ public static function get($name, $default = null)
|
||||||
/**
|
/**
|
||||||
* Set a "permanent" cookie. The cookie will last 5 years.
|
* Set a "permanent" cookie. The cookie will last 5 years.
|
||||||
*
|
*
|
||||||
* @param string $name
|
* @param string $name
|
||||||
* @param string $value
|
* @param string $value
|
||||||
* @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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the value of a cookie. If a negative number of minutes is
|
* Set the value of a cookie. If a negative number of minutes is
|
||||||
* specified, the cookie will be deleted.
|
* specified, the cookie will be deleted.
|
||||||
*
|
*
|
||||||
* @param string $name
|
* @param string $name
|
||||||
* @param string $value
|
* @param string $value
|
||||||
* @param int $minutes
|
* @param int $minutes
|
||||||
* @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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue