dd

CHttpCookie


system.web
继承 class CHttpCookie » CComponent
源自 1.0
版本 $Id: CHttpCookie.php 2799 2011-01-01 19:31:13Z qiang.xue $
源码
一个CHttpCookie实例存储一个cookie,包括cookie的名称,值,域名,路径,过期,和安全。

公共属性

属性 类型 描述 定义在
domain string cookie所在域 CHttpCookie
expire integer cookie过期的时间戳。这是服务器的时间戳。默认值为0“代表有效期直到关闭浏览器”。 CHttpCookie
httpOnly boolean cookie是否只允许通过HTTP协议访问。 通过设置这个属性为true,cookie将无法访问脚本语言, 例如JavaScript,它可以有效减少由于通过身份被盗窃而导致的XSS攻击。 注意:此属性仅适合PHP 5. CHttpCookie
name string cookie名称 CHttpCookie
path string 该cookie在服务器上的路径。默认值是‘/’。 CHttpCookie
secure boolean 是否应通过安全连接发送cookie CHttpCookie
value string cookie值 CHttpCookie

公共方法

方法 描述 定义在
__call() 如果类中没有调的方法名,则调用这个方法。 CComponent
__construct() 构造方法。 CHttpCookie
__get() 返回一个属性值、一个事件处理程序列表或一个行为名称。 CComponent
__isset() 检查一个属性是否为null。 CComponent
__set() 设置一个组件的属性值。 CComponent
__unset() 设置一个组件的属性为null。 CComponent
asa() 返回这个名字的行为对象。 CComponent
attachBehavior() 附加一个行为到组件。 CComponent
attachBehaviors() 附加一个行为列表到组件。 CComponent
attachEventHandler() 为事件附加一个事件处理程序。 CComponent
canGetProperty() 确定属性是否可读。 CComponent
canSetProperty() 确定属性是否可写。 CComponent
detachBehavior() 从组件中分离一个行为。 CComponent
detachBehaviors() 从组件中分离所有行为。 CComponent
detachEventHandler() 分离一个存在的事件处理程序。 CComponent
disableBehavior() 禁用一个附加行为。 CComponent
disableBehaviors() 禁用组件附加的所有行为。 CComponent
enableBehavior() 启用一个附加行为。 CComponent
enableBehaviors() 启用组件附加的所有行为。 CComponent
evaluateExpression() 计算一个PHP表达式,或根据组件上下文执行回调。 CComponent
getEventHandlers() 返回一个事件的附加处理程序列表。 CComponent
hasEvent() 确定一个事件是否定义。 CComponent
hasEventHandler() 检查事件是否有附加的处理程序。 CComponent
hasProperty() 确定属性是否被定义。 CComponent
raiseEvent() 发起一个事件。 CComponent

属性详细

domain 属性
public string $domain;

cookie所在域

expire 属性
public integer $expire;

cookie过期的时间戳。这是服务器的时间戳。默认值为0“代表有效期直到关闭浏览器”。

httpOnly 属性
public boolean $httpOnly;

cookie是否只允许通过HTTP协议访问。 通过设置这个属性为true,cookie将无法访问脚本语言, 例如JavaScript,它可以有效减少由于通过身份被盗窃而导致的XSS攻击。 注意:此属性仅适合PHP 5.2.0以及以上版本。

name 属性
public string $name;

cookie名称

path 属性
public string $path;

该cookie在服务器上的路径。默认值是‘/’。

secure 属性
public boolean $secure;

是否应通过安全连接发送cookie

value 属性
public string $value;

cookie值

方法详细

__construct() 方法
public void __construct(string $name, string $value)
$name string cookie名称
$value string cookie值
public function __construct($name,$value)
{
    
$this->name=$name;
    
$this->value=$value;
}

构造方法。