Reading cookies -

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
TeckniX
Forum Newbie
Posts: 4
Joined: Thu Oct 20, 2005 11:55 am

Reading cookies -

Post 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
User avatar
PrObLeM
Forum Contributor
Posts: 418
Joined: Sun Mar 07, 2004 2:30 pm
Location: Mesa, AZ
Contact:

Post by PrObLeM »

A quick google search will give you your answer. http://www.phpbuilder.com/columns/chris ... 01128.php3
User avatar
aerodromoi
Forum Contributor
Posts: 230
Joined: Sun May 07, 2006 5:21 am

Re: Reading cookies -

Post 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
Post Reply