Delete PHP Cookie?

前端 未结 3 1284
醉梦人生
醉梦人生 2020-12-20 18:04

I currently have a cookie set as follows:

setcookie(\"username\",$username,time()+3600*24*5);

How would I go about clearing the value of th

3条回答
  •  温柔的废话
    2020-12-20 18:35

    Be sure that you delete the cookie with the same domain name and path with which you set it. Cookies for example.com and www.example.com will be treated as two different cookies. Similarly, cookies set from example.com and example.com/Support will have different paths. A good practice is to use .example.com as the domain and '/' as the path for username type cookies so that they can be shared across your subdomains too.

    To debug this, you can use the FireCookie plugin of Firefox which'll show all this information.

提交回复
热议问题