php cookie doesn't update

前端 未结 5 540
遥遥无期
遥遥无期 2021-01-21 17:08

I need to update a cookie. I do that in a php file called via ajax. This is is the code:

setcookie(\'items[\'.$_POST[\'id\'].\']\');

The cookie

5条回答
  •  难免孤独
    2021-01-21 17:40

    From php.net/manual/function.setcookie.php:

    Cookies will not become visible until the next loading of a page that the cookie should be visible for. To test if a cookie was successfully set, check for the cookie on a next loading page before the cookie expires. Expire time is set via the expire parameter. A nice way to debug the existence of cookies is by simply calling print_r($_COOKIE);.

    So the cookie will be accessible via $_COOKIE at the request of the PHP script.

提交回复
热议问题