Re: Re: Setting cookie for two domains.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



that is some nice out-of-the-box thinking Mark!

Mark wrote:
Shafiq Rehman wrote:


Hi,

How can I register a session or cookie for two domains. I want to maintain
logged user's state when he goes from one domain to other domain.

Example
Suppose a user is logged in on domain1.com. A cookie is set and user is
authenticated from database on the basis of that cookie. When he goes from
domain1.com to domain2.com, I want he remains loggedin on domain2.com. I
do not want any query string. Is it possible by playing with cookie or
session settings?

Please advise if anybody has faced such problem.


I have been giving this problem some more thought and I think I have an
answer for you. My previous response was pretty invasive if you don't have
full control or knowledge of the web session code.

Assuming you index by some session ID, and that ID can be shared across
sites.

You make a graphical bug or link.

On both servers you create a PHP file that accepts a URL parameter, sets a
cookie, and displays an image. Something like:


mylogo.php

<?
        $sid = $_GET['phpsession'];
        setcookie ("PHPSESSID", $sid);
        # Now redirect to some image, either open it or set redirect flag
?>


Now in BOTH websites, render an image on your page as:

site 1:
<img
src="http://www.site2.org/mylogo.php?phpsession=hddfewfelkfjewlkewflkjlkweweio";>

site 2:
<img
src="http://www.site1.org/mylogo.php?phpsession=hddfewfelkfjewlkewflkjlkweweio";>


This way, you pass the cookie to both sites.


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux