PHP read a cookie that is on another domain

前端 未结 6 857
孤街浪徒
孤街浪徒 2020-12-20 20:22

I have two domains. One domain contains the login script. It creates a cookie when logged in. Another domain have a URL shortener.

So, on the 2nd domain that have th

6条回答
  •  渐次进展
    2020-12-20 20:46

    Cookies are sent by the browser and only to the domain, the cookies were set for.

    There is not much (meaning nothing ;) ) you can do.

    But if your domains are two different subdomains (e.g. login.yourdomain.com and shortener.yourdomain.com) you just have to set the domain name accordingly to make the cookie valid for all subdomains.
    In this case, it would be .yourdomain.com.

    You might want to read the documentation of setcookie().


    Maybe it is better if you clearly describe what you want to accomplish. Probably there is another solution that does not involve cookies.

提交回复
热议问题