Jump to content

One Cookie For multiple Domain


sunshine33

Recommended Posts

Hi All,

 

I want to shared between some website (community) a same cookie to allowed users to login only once.

 

It means I've to create a cookie for a main domain and each domain have to read it.

 

I found this code, it allow, in theorie, to create a cookie for another domain of the current domain .. but it doesn't work well :

 

 
header("P3P: policyref=\"http://www.nomdomaine.com/p3p.xml\",CP=\"NON DSP COR CURa PSA PSD OUR BUS NAV STA\"");
setcookie("moncookie",$valeurducookie, time()+(3600*$nb_heures), "/", "nomdomaine.com",0);

 

p3p.xml :

 
<?xml version="1.0" encoding="UTF-8" ?>
<META xmlns="http://www.w3.org/2000/12/P3Pv1">
<POLICY-REFERENCES>
   <POLICY-REF about="/w3c/policy.xml">
     <INCLUDE>/*</INCLUDE>
     <COOKIE-INCLUDE>* * *</COOKIE-INCLUDE>      
   </POLICY-REF>
</POLICY-REFERENCES>
</META>

 

 

I know it is possible to do it. For example : http://www.xiti.com/en/home.aspx

When you visit a website with the xiti tag, it create a cookie for the xiti domain even the website isn't xiti !!!

So, it is possible to do it, but I can't find how to do it ?

 

If somebody can help me, I'll really appreciate  :wink:

 

Thanks al ot

Link to comment
Share on other sites

You can't "really" share a cookie across multiple domains - only sub-domains.

 

According to this page http://www.15seconds.com/issue/971108.htm (which is about ASP, but the logic is valid for PHP), making a COOKIE available across domains is more of a "trick" than a function.

 

The first domain will issue the cookie, and the second domain will request the cookie from the first. However, you need to be VERY careful here. If you don't put up proper security, then a 3rd party site could access cookies from your site. Just make sure any requests are from your domains.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.