setrawcookie()
函数用于设置一个原始的 HTTP cookie。
语法:
bool setrawcookie ( string $name [, string $value = "" [, int $expire = 0 [, string $path = "" [, string $domain = "" [, bool $secure = false [, bool $httponly = false ]]]]]] )
参数:
$name
:cookie 的名称。$value
:cookie 的值。$expire
:cookie 的过期时间,使用 Unix 时间戳表示。默认为 0,表示会话结束时过期。$path
:cookie 可用的路径。默认为空字符串,表示当前路径及其子路径。$domain
:cookie 可用的域名。默认为空字符串,表示当前域名及其子域名。$secure
:如果为 true
,则只在使用 HTTPS 连接时发送 cookie。默认为 false
。$httponly
:如果为 true
,则 cookie 只能通过 HTTP 协议访问,不能通过 JavaScript 访问。默认为 false
。返回值:
true
。false
。示例:
setrawcookie("username", "john", time()+3600, "/", ".example.com", true, true);
上述示例将设置一个名为 "username" 的 cookie,值为 "john",过期时间为当前时间加上 3600 秒(1小时),可用的路径为根路径,可用的域名为 ".example.com",只能通过 HTTPS 连接发送,只能通过 HTTP 协议访问。
上一篇:php剔除数组里的元素
下一篇:php中英文字符串转数组
Laravel PHP 深圳智简公司。版权所有©2023-2043 LaravelPHP 粤ICP备2021048745号-3
Laravel 中文站