Home > Article > Backend Development > 用setCookie()时,将域名指定称“localhost”就保存不了Cookie咋回事?
用setCookie()时,将域名指定称“localhost”就保存不了Cookie怎么回事??
在本地测试的时候发现的。
这样可以设置Cookie:
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--> setCookie('name[1]', 'yy1', time() + 3600, '/'); setCookie('name[2]', 'yy2', time() + 3600, '/');
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--> setCookie('name[1]', 'yy1', time() + 3600, '/', 'localhost'); setCookie('name[2]', 'yy2', time() + 3600, '/', 'localhost');