Sunday, March 13, 2022

[FIXED] How do you update a cookie in PHP?

Issue

If I call setcookie() two times with the same cookie name, I get two cookies created.

How do you update an existing cookie?


Solution

You can't update a cookie per se, you can however overwrite it. Otherwise, this is what you are looking for: http://php.net/manual/en/function.setcookie.php

It works. Be sure to read "Common Pitfalls" from that page.

You can use the super global $_COOKIE['cookie_name'] as well to read cookies.



Answered By - Francisc

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.