setcookie to an empty value not working

前端 未结 5 2094
天涯浪人
天涯浪人 2020-12-21 06:46

i have this code im trying to do for a type of cache system so it remembers the city the user has selected. if the user has selected a city it stores it in sessions and cook

5条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-21 07:43

    You can't set a cookie with an empty string as it will delete the cookie.

    From the docs:

    If the value argument is an empty string, or FALSE, and all other arguments match a previous call to setcookie, then the cookie with the specified name will be deleted from the remote client.

提交回复
热议问题