One Cookie For multiple Domain

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
sunshine33
Forum Newbie
Posts: 1
Joined: Wed Feb 06, 2008 9:55 am

One Cookie For multiple Domain

Post by sunshine33 »

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 :

Code: Select all

 
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 :

Code: Select all

 
<?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
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: One Cookie For multiple Domain

Post by Christopher »

You should look into standard single-signin solutions. Usually there is either a shared datasource or parameters are passed that can be verified using a web-service of some sort.
(#10850)
Post Reply