search
Homephp教程php手册php cookies中删除的一般赋值方法

php cookies中删除的一般赋值方法 cookie 常用于识别用户。cookie 是服务器留在用户计算机中的小文件。

php cookies中删除的一般赋值方法 cookie 常用于识别用户。cookie 是服务器留在用户计算机中的小文件。每当相同的计算机通过浏览器请求页面时,它同时会发送 cookie。通过 php,您能够创建并取回 cookie 的值
语法
代码如下:
setcookie(name, value, expire, path, domain);
**
* 设置cookie
* n 名称
* c 值
* e 有效期 0 默认 一个月 1 关闭立即失效
*/

function w_cookie($n, $c, $e = 0,$isdes=1)
{
if($isdes==1){$c=endes($c,deskey);}
$exp = time() + 3600 * 24 * 30;
if($e == 0)
{
setcookie($n, $c, $exp,"/");
}
else
{
setcookie($n, $c,0,"/");
}
}

//关闭cookie方法
w_cookie('bb', 'www.3ppt.com', $e = 0,$isdes=1);
function set_cronology($name,$value,$duration=7){
$duration=time()+(3600*24*$duration);
$max_stored_values=5;
if(isset($_cookie[$name])){
foreach($_cookie[$name] as $prop_crono=>$val_crono){
if($val_crono==$value)
return;
}
if($prop_cronosetcookie($name.'['.($prop_crono+1).']',$value,$duration);
else{
array_shift($_cookie[$name]);
setcookie("$name[$max_stored_values]",$value,$duration);
}
}else
setcookie($name.'[0]',$value,$duration);
return;
}
?>

注释:setcookie() 函数必须位于 标签之前。在发送 cookie 时,cookie 的值会自动进行 url 编码,在取回时进行自动解码(为防止 url 编码,请使用 setrawcookie() 取而代之)。
Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.