创建cookie 详细请参考setcookie函数参数
boolean Core_Cookie::set( string/array $name [, string $value = null , number $expire = null , string $path = string(1) "/" , string $domain = null , boolean $secure = null , boolean $httponly = null ] )
参数列表
参数 类型 描述 默认值 $name
string/array
$name $value
string
$value null $expire
number
$expire null $path
string
$path string(1) "/" $domain
string
$domain null $secure
boolean
$secure null $httponly
boolean
$httponly null
boolean
true/false
54555657585960616263646566676869707172737475767778public
static
function
set(
$name
,
$value
= null,
$expire
= null,
$path
=
'/'
,
$domain
= null,
$secure
= null,
$httponly
= null)
{
if
( headers_sent() )
return
false;
// If the name param is an array, we import it
is_array
(
$name
)
and
extract(
$name
, EXTR_OVERWRITE);
// Fetch default options
foreach
(
array
(
'value'
,
'expire'
,
'domain'
,
'path'
,
'secure'
,
'httponly'
,
'prefix'
)
as
$item
)
{
if
( $
$item
=== null && isset(Cookie::
$config
[
$item
]) )
{
$
$item
= Cookie::
$config
[
$item
];
}
}
Cookie::
$config
[
'prefix'
] &&
$name
= Cookie::
$config
[
'prefix'
] .
$name
;
// Expiration timestamp
$expire
= (
$expire
== 0) ? 0 :
$_SERVER
[
'REQUEST_TIME'
] + (int)
$expire
;
Cookie::check_domain(
$domain
);
return
setcookie(
$name
,
$value
,
$expire
,
$path
,
$domain
,
$secure
,
$httponly
);
}