Multiple cookies with the same name

I just realized that I have a problem with IE, working from one of my pages. I set a cookie using

setcookie('page', '12345', '2000000', '/');

And if I log in I reset, the cookie calls this function again. Everything works fine in firefox because the old cookie is deleted, but in IE, both cookies remain? How can this happen? Isn't that illegal?

I have now fixed this with:

setcookie('page', '', time() - 3600, '/');
setcookie('page', '1234', '2000000', '/');

Is this normal, or am I missing something?

+3
source share
3 answers

According to the documentation , this is the correct way to delete a cookie.

+4
source

, , expires , , , ( ). , - IE, cookie?

time(), , :

setcookie('page', '12345', time() + 3600, '/');

Btw, .

+1

.

, session_start() , . JavaScript cookie, PHP. Internet Explorer, $_ENV [ "HTTP_COOKIE" ] cookie. Firefox.

, x.y.z Internet Explorer cookie x.y.z, cookie y.z. PHP cookie $_ENV [ "HTTP_COOKIE" ].

Perhaps this can be considered a PHP error, perhaps not. IMHO, this is an Internet Explorer bug. I post it here, hoping that it will help you solve your problem.

0
source

Source: https://habr.com/ru/post/1726003/


All Articles