How do you update a cookie in PHP?

前端 未结 5 2003
清酒与你
清酒与你 2020-12-30 23:06

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

How do you update an existing cookie?

5条回答
  •  无人及你
    2020-12-30 23:21

    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/write cookies.

提交回复
热议问题