user1386869
user1386869

Reputation: 33

Using cookies in 2 distincts websites

I have 2 websites and I would like to use the same cookie for both websites. The problem is they are not in the same domain.

How can I do ?

Upvotes: 0

Views: 62

Answers (3)

Headshota
Headshota

Reputation: 21449

You can set two cookies for both domains, example PHP code:

setcookie("TestCookie", "value", $path, "domain1.com");
setcookie("TestCookie", "value", $path, "domain2.com");

Link:

http://php.net/manual/en/function.setcookie.php

Upvotes: 1

Nicolas BADIA
Nicolas BADIA

Reputation: 5852

You can't do that with cookies.

You have to save the data of your cookies on your server. You can use a database to do this.

Upvotes: 0

Oscar
Oscar

Reputation: 13990

I guess you can't. Cookies are only sent to the domain they belong to. You most create diferent cookies to both diferent domains.

Upvotes: 0

Related Questions