You are here: Re: [PHP] Re: Setting cookie for two domains. « PHP « IT news, forums, messages
Re: [PHP] Re: Setting cookie for two domains.

Posted by Jochem Maas on 09/30/30 11:36

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.
>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация