PHP Can't read cookies?

前端 未结 4 1457
轮回少年
轮回少年 2021-01-22 12:03

I like to use PHP to see if a cookie PHPSID27258STATUS is present with the value COMPLETE en if so do stuff.

In google chrome (in Options) I ca

4条回答
  •  旧巷少年郎
    2021-01-22 12:20

    Try setting the cookie with this code:

    setcookie("cookiename", "cookievalue", time() + 31536000, "/");
    

    This makes the cookie available to the whole domain, I recently encountered the same issue and when I tried this, it made it work, the reason is, your browser stores cookies for both domain.com and www.domain.com so you never know which your setting and getting from, it's good practice to set the domain even if you don't have this problem.

提交回复
热议问题