[英]Secure cookie not working in php
I am trying to set the secure cookie into localhost and it doesn't work for me. 我试图将安全cookie设置为localhost,但对我来说不起作用。 My code is below :
我的代码如下:
<?php
setcookie("TestCookie", "value1hostonly", time(), "/", "localhost.com", 0, true);
setcookie("TestCookie2", "value2subdom", time(), "/", "localhost", 0, true);
echo @$_COOKIE["TestCookie"];
echo @$_COOKIE["TestCookie2"];
?>
Output always show blank . 输出始终显示为空白。 Please guide me.
请指导我。
Your expiration time is set to now. 您的到期时间设置为现在。
Change time()
to time() + 500
or however many seconds until cookie expires. 将
time()
更改为time() + 500
或者更改为几秒钟,直到Cookie过期。
Secure cookie not work on localhost . 安全cookie在localhost上不起作用。 need to test it on server and Change time() to time() + 500 or however many seconds until cookie expires .
需要在服务器上对其进行测试,并将time()更改为time()+ 500或任意几秒钟,直到cookie过期。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.