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
quilby
Forum Newbie
Posts: 13 Joined: Wed Jun 13, 2007 2:22 am
Post
by quilby » Fri Oct 12, 2007 5:44 am
I want to make it so that when a user logs on to site1.com he will get a cookie with a user ID, and then when he goes to site2.com (which is on a different domain and server), the site will know his user ID. Is there a way to do this by lets say putting a widget or something like that by site1.com on site2.com?
Thanks!
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Fri Oct 12, 2007 9:34 pm
Cookies do not communicate across domains. You will need to figure out a different mechanism.
quilby
Forum Newbie
Posts: 13 Joined: Wed Jun 13, 2007 2:22 am
Post
by quilby » Sat Oct 13, 2007 8:43 am
Lets say a picture is which is hosted on site1.com is displayed on site2.com, can site1.com still read cookies from people browsing site2?
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Sat Oct 13, 2007 9:08 am
As I said, cookies are not communicated across domains.
markg85
Forum Commoner
Posts: 32 Joined: Sat Dec 03, 2005 6:49 pm
Post
by markg85 » Sat Oct 13, 2007 10:24 am
perhaps sessions stored on the server can help with this?
i don't know it.. just a guess.
quilby
Forum Newbie
Posts: 13 Joined: Wed Jun 13, 2007 2:22 am
Post
by quilby » Sat Oct 13, 2007 11:23 am
Ok, because I thought that there was away to get two domains to read the same cookie.
What I want to do is have user info stored on his browser so that when he leaves site1.com and goes to site2.com site2.com knows his UID and a couple more things, without having to ask him to log in.
Is there any other way to do this?
EDIT: BTW, the two websites are on different servers...
Last edited by
quilby on Sat Oct 13, 2007 11:26 am, edited 1 time in total.
superdezign
DevNet Master
Posts: 4135 Joined: Sat Jan 20, 2007 11:06 pm
Post
by superdezign » Sat Oct 13, 2007 11:25 am
You could handle this via the database and access it from a different domain.
quilby
Forum Newbie
Posts: 13 Joined: Wed Jun 13, 2007 2:22 am
Post
by quilby » Sat Oct 13, 2007 11:33 am
What do you mean?
I want it so that the user does not have to log in.
John Cartwright
Site Admin
Posts: 11470 Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:
Post
by John Cartwright » Sat Oct 13, 2007 11:42 am
You can have the site create the cookie for both domains when it is created. Just make sure you set the domain parameter to the other server's domain.
bool setcookie ( string $name [, string $value [, int $expire [, string $path [, string $domain [, bool $secure [, bool $httponly]]]]]] )
quilby
Forum Newbie
Posts: 13 Joined: Wed Jun 13, 2007 2:22 am
Post
by quilby » Sat Oct 13, 2007 12:19 pm
What if I want 10 domains to be able to access the cookie? Or even 1,000 domains. Can I do this?
John Cartwright
Site Admin
Posts: 11470 Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:
Post
by John Cartwright » Sat Oct 13, 2007 12:22 pm
No. You cannot read cookies from other domains. Period.
quilby
Forum Newbie
Posts: 13 Joined: Wed Jun 13, 2007 2:22 am
Post
by quilby » Sat Oct 13, 2007 12:25 pm
Ok so is there any way to do what I mentioned in the reply above?
nickvd
DevNet Resident
Posts: 1027 Joined: Thu Mar 10, 2005 5:27 pm
Location: Southern Ontario
Contact:
Post
by nickvd » Sat Oct 13, 2007 1:36 pm
superdezign wrote: You could handle this via the database and access it from a different domain.
quilby
Forum Newbie
Posts: 13 Joined: Wed Jun 13, 2007 2:22 am
Post
by quilby » Sat Oct 13, 2007 4:51 pm
Yeah but I dont want the user to log in.
John Cartwright
Site Admin
Posts: 11470 Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:
Post
by John Cartwright » Sat Oct 13, 2007 4:51 pm
quilby wrote: Yeah but I dont want the user to log in.
Whats that have to do with anything?