You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
66 lines
1.7 KiB
66 lines
1.7 KiB
13 years ago
|
<?php
|
||
|
/**
|
||
|
* @link http://www.yiiframework.com/
|
||
12 years ago
|
* @copyright Copyright (c) 2008 Yii Software LLC
|
||
13 years ago
|
* @license http://www.yiiframework.com/license/
|
||
|
*/
|
||
|
|
||
12 years ago
|
namespace yii\web;
|
||
|
|
||
13 years ago
|
/**
|
||
12 years ago
|
* Cookie represents information related with a cookie, such as [[name]], [[value]], [[domain]], etc.
|
||
13 years ago
|
*
|
||
|
* @author Qiang Xue <qiang.xue@gmail.com>
|
||
12 years ago
|
* @since 2.0
|
||
13 years ago
|
*/
|
||
12 years ago
|
class Cookie extends \yii\base\Object
|
||
13 years ago
|
{
|
||
|
/**
|
||
|
* @var string name of the cookie
|
||
|
*/
|
||
|
public $name;
|
||
|
/**
|
||
|
* @var string value of the cookie
|
||
|
*/
|
||
12 years ago
|
public $value = '';
|
||
13 years ago
|
/**
|
||
|
* @var string domain of the cookie
|
||
|
*/
|
||
12 years ago
|
public $domain = '';
|
||
13 years ago
|
/**
|
||
12 years ago
|
* @var integer the timestamp at which the cookie expires. This is the server timestamp.
|
||
|
* Defaults to 0, meaning "until the browser is closed".
|
||
13 years ago
|
*/
|
||
12 years ago
|
public $expire = 0;
|
||
13 years ago
|
/**
|
||
|
* @var string the path on the server in which the cookie will be available on. The default is '/'.
|
||
|
*/
|
||
12 years ago
|
public $path = '/';
|
||
13 years ago
|
/**
|
||
|
* @var boolean whether cookie should be sent via secure connection
|
||
|
*/
|
||
12 years ago
|
public $secure = false;
|
||
13 years ago
|
/**
|
||
|
* @var boolean whether the cookie should be accessible only through the HTTP protocol.
|
||
|
* By setting this property to true, the cookie will not be accessible by scripting languages,
|
||
12 years ago
|
* such as JavaScript, which can effectively help to reduce identity theft through XSS attacks.
|
||
13 years ago
|
*/
|
||
12 years ago
|
public $httponly = false;
|
||
12 years ago
|
|
||
|
/**
|
||
|
* Magic method to turn a cookie object into a string without having to explicitly access [[value]].
|
||
|
*
|
||
|
* ~~~
|
||
|
* if (isset($request->cookies['name'])) {
|
||
|
* $value = (string)$request->cookies['name'];
|
||
|
* }
|
||
|
* ~~~
|
||
|
*
|
||
|
* @return string The value of the cookie. If the value property is null, an empty string will be returned.
|
||
|
*/
|
||
|
public function __toString()
|
||
|
{
|
||
|
return (string)$this->value;
|
||
|
}
|
||
13 years ago
|
}
|