简体   繁体   中英

Secure cookie not working in php

I am trying to set the secure cookie into localhost and it doesn't work for me. 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.

Secure cookie not work on localhost . need to test it on server and Change time() to time() + 500 or however many seconds until cookie expires .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM