When setCookie () is used, the Cookie cannot be saved if the domain name is specified as "localhost". why ?? Found during local testing. In this way, you can set the Cookie: PHPcodesetCookie (name [1], yy1, time () + 3600,); setCookie (name [2], yy2, time () + 3600 using setCookie () when the domain name is specified as "localhost", the Cookie cannot be saved. why ??
Found during local testing.
In this way, you can set the Cookie:
PHP code
setCookie('name[1]', 'yy1', time() + 3600, '/'); setCookie('name[2]', 'yy2', time() + 3600, '/');
This will not work:
PHP code
setCookie('name[1]', 'yy1', time() + 3600, '/', 'localhost'); setCookie('name[2]', 'yy2', time() + 3600, '/', 'localhost');
Why? Is the parameter "localhost" incorrect ???
Thank you!
------ Solution --------------------
When working on localhost the cookie-domain must be set to "" or NULL or FALSE
------ Solution --------------------
Discussion
When working on localhost the cookie-domain must be set to "" or NULL or FALSE