Warm tip: This article is reproduced from stackoverflow.com, please click
cookies php setcookie

setcookie not working on safari and firefox

发布于 2020-04-11 22:24:28

I'm trying to set cookies on my project, but it is not working on Safari or Firefox.

I get results on Google Chrome though.

Here is my code:

 setcookie('mycookiename', 'data', time()+60*60*24*365, '/', false);
 print_r($_COOKIE['mycookiename']);

Thanks for help.

Questioner
ayoubben
Viewed
90
Suman 2016-07-12 03:27

This code work properly

setcookie("mycookiename", 'data', time()+60*60*24*365, "/", "", "", TRUE);
print_r($_COOKIE['mycookiename']);