Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cookie - Why cookie showing in browser after it deleted by using PHP code

Why cookie values showing in browser even after it deleted by using PHP code, I am viewing cookie values by using FireFox "View Cookies addon". It will disappear only after delete or clear my browser cookies manually. I asking this question because of my work will work only after deleting cookies from browser manually, if i unset cookie in PHP code and run , it will not work, i am un setting cookie value by setting its expire date with past value.Example:

setcookie ("myCookie", "", time() - 3600, "/", ".example.com");

Code I am using for setting cookie:

setcookie ('Event', '', time() - 3600, '/', '.example.com');

Code I am using for unsetting cookie:

setcookie('Event', '-1-1301223453%7C9de8f7c08bf2be19c125f86ced33a0c2%7C1301050653%7C-1%7C1301223453', '', '/', '.example.com', 0);

But if i print cookie value after it unset it will be blank(nothing), but it will show in browser

Please any one help!!

like image 207
Saritha Avatar asked Mar 21 '26 19:03

Saritha


1 Answers

That is completely based on browser settings you are viewing in and you are asking that the browser is still showing the cookies. That is true browser is still showing the cookies but you will get relax when you check it in PHP the cookie is unset.

print_r($_COOKIE);

show you the active cookies.

Remember when you clear cookies from your browser tool then cookie will be erased but when you unset from the PHP they are set to the time in past not erased from browser history.

like image 180
Shakti Singh Avatar answered Mar 24 '26 08:03

Shakti Singh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!