fanfavorite Posted October 1, 2010 Share Posted October 1, 2010 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 https://forums.phpfreaks.com/topic/214905-sessions-across-domains/ Share on other sites More sharing options...
DarkMantis Posted October 1, 2010 Share Posted October 1, 2010 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 https://forums.phpfreaks.com/topic/214905-sessions-across-domains/#findComment-1117949 Share on other sites More sharing options...
fanfavorite Posted October 1, 2010 Author Share Posted October 1, 2010 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 https://forums.phpfreaks.com/topic/214905-sessions-across-domains/#findComment-1117953 Share on other sites More sharing options...
DarkMantis Posted October 1, 2010 Share Posted October 1, 2010 Ohh right. Sorry I must have missed that one out. Here is the equivilent in ASP.net (I think) http://msdn.microsoft.com/en-us/library/5t9y35bd%28vs.71%29.aspx Link to comment https://forums.phpfreaks.com/topic/214905-sessions-across-domains/#findComment-1117960 Share on other sites More sharing options...
fanfavorite Posted October 1, 2010 Author Share Posted October 1, 2010 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 https://forums.phpfreaks.com/topic/214905-sessions-across-domains/#findComment-1117971 Share on other sites More sharing options...
roopurt18 Posted October 1, 2010 Share Posted October 1, 2010 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 https://forums.phpfreaks.com/topic/214905-sessions-across-domains/#findComment-1118108 Share on other sites More sharing options...
fanfavorite Posted October 1, 2010 Author Share Posted October 1, 2010 Ok, that makes sense. Do you have any sample php code to do that? Thanks. Link to comment https://forums.phpfreaks.com/topic/214905-sessions-across-domains/#findComment-1118129 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.