Page 1 of 1

Reading cookies -

Posted: Sun Jun 04, 2006 2:14 pm
by TeckniX
I'm quite familiar with cookies and I can successfully set them and read them -
On my server I host multiple domains example.com, website.com, example.net .... you get the drift.

My question is, how can I read the cookie set by one of my other domains - when a user logs into one of my domain, I'd like to keep him logged in no matter what site he goes to, or at least recognize his credentials and ask for his password again -
I'm setting the cookie without any domain-name, but when I try to read the cookie with:

Code: Select all

<?php 
echo $_cookie["LOGINID"];
?>
It tries to read the current domain's cookie, which of course isn't always right -

What I'm wondering is, can I read the cookie set by one of my other domains? Is there a way to specify in php what domain to read the cookie from?
So I could do something like:

Code: Select all

<?php
echo $_cookie["domain"]["LOGINID"]; 
?>
Thanks

Posted: Sun Jun 04, 2006 2:32 pm
by PrObLeM
A quick google search will give you your answer. http://www.phpbuilder.com/columns/chris ... 01128.php3

Re: Reading cookies -

Posted: Sun Jun 04, 2006 4:32 pm
by aerodromoi
TeckniX wrote: What I'm wondering is, can I read the cookie set by one of my other domains? Is there a way to specify in php what domain to read the cookie from?
So I could do something like:

Code: Select all

<?php
echo $_cookie["domain"]["LOGINID"]; 
?>
Thanks
If this was possible, this would be a security nightmare :(

However, even though indexonserver1.php can't read the cookies set by indexonserver2.php,
image1fromserver1linkedonserver2.php can.

aerodromoi