Jump to content

Sessions Across Domains


fanfavorite

Recommended Posts

Hey All,

 

What I am trying to do is link a whole bunch of our sites together to be seamless when users are on them, even though they are actually on different servers.  For example, we have portal.ourdomain.com which runs our billing software, www.ourdomain.com which is our regular website, cp.ourdomain.com which is our control panel and mail.ourdomain.com which is our webmail login.  We have a common header, which needs the session variables and such from the portal site.  So we created a separate header file (on the portal site) that could be used by the other sites to read in.  Now the separate file works by going to it directly portal.ourdomain.com/commonheader.php, however when included on the external pages, it doesn't get the number of items in the cart or the logged in state.  I assume that this probably has to do with the sessions, but my question is, is there a way to process the file before it is included.  I was hoping that it could read the file output, rather than generate it within the external site.

 

Let me know if any one of you know of any ways to do what I am trying.  If I am confusing you, just let me know what needs clarification.

 

 

Thanks.

Link to comment
Share on other sites

Heyy.

 

I was just reading your post, and the best way I thought of doing this would be by using cURL.

 

I've never used it to the extent that I want to run one site on multiple servers, but I wouldn't be at all surprised if it worked for what you want it to. I don't know enough about it to actually give you the answer, plus what fun is that ;)

 

Here is the PHP.net manual for cURL_setopt();

 

http://php.net/manual/en/function.curl-setopt.php

 

Hope this helps!

 

~~

DarkMantis!

Link to comment
Share on other sites

Thanks.  cURL would probably work for the servers supporting php and cURL, the problem is one server is asp.net.  There probably is a something that will do something like cURL for asp.net as well, so this may be an option. 

 

I am hoping there may be an easier option, but if not, I will work with this. 

 

Thanks. 

Link to comment
Share on other sites

Thanks I didn't mention the asp.net thing before, so you didn't miss anything!  Anyways, I tried the cURL option, but that doesn't seem to be working:

 

$ch = curl_init('https://portal.ourdomain.com/commonheader.php');

curl_setopt($ch, CURLOPT_COOKIEJAR, "cookie.txt");

curl_setopt($ch, CURLOPT_COOKIEFILE, "cookie.txt");

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$result = @curl_exec($ch);

echo $result;

Link to comment
Share on other sites

If the user logs into ServerA and then ServerA uses cURL to log into ServerB, the cookie returned by ServerB will reside on ServerA and not on the client's machine.  You need to send the cookie data from ServerB back down to the client so that the client can "hijack" their own session.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.