开发者

Transfer cookie from one domain to another on different servers [duplicate]

开发者 https://www.devze.com 2023-04-09 00:52 出处:网络
This question already has answers here: 开发者_高级运维Closed 11 years ago. Possible Duplicate: How do I use cookies across two different domains?
This question already has answers here: 开发者_高级运维 Closed 11 years ago.

Possible Duplicate:

How do I use cookies across two different domains?

Can you please tell me what is the easiest way to transfer cookies from one domain to another on different servers?

I have a website and a forum on different servers and different domains. I've already created the bridge between them regarding users.

Thanks.


You could do a an Ajax call from one server to the other, and rebuilding the session on the other server.

To use cross domain you need to use JsonP. Take a look here: http://api.jquery.com/jQuery.ajax/

This way, the site does do a request as the user, so the cookie/session does exists on the other server, and therefore you can set a new one.


Basicly: You can't.

Actually, this constitutes two problems:

  • The split domain issue. If you have different subdomains (i.e. blog.example.net and www.example.net) you can set the domain to example.net for the cookie. If it is entirely different domains, please refer to the solution found on How do I use cookies across two different domains?
  • The split server issue. For this, you need to write your own session management which can be distributed over several servers, i.e. via a separate database server. Please refer to the php docs on this matter.
0

精彩评论

暂无评论...
验证码 换一张
取 消