安全cookie无法在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.

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 .

Your expiration time is set to now.

Change time() to time() + 500 or however many seconds until cookie expires.