请问setcookie不设定到期时间,设定路径该怎么写?

PHP中文网
Release: 2023-02-28 17:20:01
Original
2210 people have browsed it

请问setcookie不设定到期时间,设定路径该怎么写?

以下几种写法都不生效:  

setcookie(mycookie,'11','','/');  
 setcookie(mycookie,'11',,'/');  
 setcookie(mycookie,'11','/');
Copy after login

但这样写就成:

setcookie(mycookie,'11',time()+31104000,'/');
Copy after login

可我不想指到到期时间,我想一关闭浏览器COOKIE就删除。

看网上的教程,都没写明这种情况该怎样写啊。
谁帮忙解答一下,谢谢!

回复讨论(解决方案)

用session吧

我希望用COOKIE做,不可以吗?

或者

setcookie("mycookie", '11');
setcookie("mycookie", '11');
Copy after login

这样就不能指定目录了啊

setcookie('mycookie','11',0,'/');
Copy after login

手册上说的不是很清楚的吗?  
因为参数 expire 是整型,不能用空字符串掉过,可以用零(0)来代替 

谢谢大家解答:)

以上就是请问setcookie不设定到期时间,设定路径该怎么写?的内容,更多相关内容请关注PHP中文网(www.php.cn)!

相关文章:

PHP setcookie用法

php setcookie函数失效

cookies设置 PHP setcookie设置Cookie用法及设置无效的问题

source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template