How to set a cookie for another domain

后端 未结 11 1980
一向
一向 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:55

    Here is what I've used. Note, this cookie is passed in the open (http) and is therefore insecure. I don't use it for anything which requires security.

    1. Site A generates a token and passes as a URL parameter to site B.
    2. Site B takes the token and sets it as a session cookie.

    You could probably add encryption/signatures to make this secure. Do your research on how to do that correctly.

提交回复
热议问题