How to set a cookie for another domain

后端 未结 11 1792
一向
一向 2020-11-22 07:21

Say I have a website called a.com, and when a specific page of this site is loaded, say page link, I like to set a cookie for another site called b.com

11条回答
  •  忘了有多久
    2020-11-22 07:35

    You cannot set cookies for another domain. Allowing this would present an enormous security flaw.

    You need to get b.com to set the cookie. If a.com redirect the user to b.com/setcookie.php?c=value

    The setcookie script could contain the following to set the cookie and redirect to the correct page on b.com

    
    

提交回复
热议问题