|
Posted by Mark on 11/14/19 11:36
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]
|