phpcookieshttpcookiecakephp

How do you update a cookie in PHP?


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.