Solved

Share PHP session variablr across different domain names on same Apache server

Posted on 2010-11-10
18
594 Views
Last Modified: 2012-06-21
I want to be able to share a session variable $_SESSION across different domain names on the same server.

I have different domains on the same server and I want to be able to share a session variable.

www.site1.com
www.site2.com
...
www.siteN.com

all www.siteX.com are on the same server and I want $_SESSION['share_foo'] to be shared across www.site1.com to www.siteN.com
0
Comment
Question by:pmsguy
18 Comments
 
LVL 108

Accepted Solution

by:
Ray Paseur earned 168 total points
Comment Utility
Can't be done without a lot of pain.  You need cookies for the session handler to work.  Cookies are set and retrieved on a per-domain basis.  So the difference between site1.com and site2. com is as big as the difference between google.com and facebook.com
0
 
LVL 108

Expert Comment

by:Ray Paseur
Comment Utility
Having said that, there are commercial networks that facilitate cookie sharing.  Are you familiar with how doubleclick works?
0
 
LVL 10

Assisted Solution

by:Tyler Laczko
Tyler Laczko earned 166 total points
Comment Utility
You can create update pages that would sync your SESSION variables from site1.com and site2.com

you could write the session variables out to a file and read out from that file etc.
0
 
LVL 108

Expert Comment

by:Ray Paseur
Comment Utility
@professionalc…

I would like to see an example of those solutions.  Can you please post working scripts that will do that?  Thanks, ~Ray
0
 
LVL 5

Assisted Solution

by:SimonDard
SimonDard earned 166 total points
Comment Utility
Sharing the session cache between domains and adding the session-ID to URL's should work (might need some altering of the session loading code). It's not very secure though.
0
 

Author Comment

by:pmsguy
Comment Utility
I need to find out how to do this using symbolic links on the server.
0
 
LVL 108

Expert Comment

by:Ray Paseur
Comment Utility
Please give us an example of what you mean by "symbolic links on the server."
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 108

Expert Comment

by:Ray Paseur
Comment Utility
I object to deleting this.  Please give us an example of what you mean by "symbolic links on the server."  Are you familiar with how doubleclick works?  There may be answers, but we need to understand where you're coming from if we are going to be able to help, thanks. ~Ray
0
 

Author Comment

by:pmsguy
Comment Utility
To the Community Support Moderator,

I take offense to your comment "Closing or deleting a question with a nonsense reason or without responding fully to the participants shows a lack of courtesy to those who tried to assist you"

Sometimes, a valid reason to close a ticket is "I did not get any helpful solutions".

Do NOT forget I am a paying customer.  I pay for this service.
This is not just a blog, I pay for this service to get expedited answers.

I reply to almost all of the questions with dignity and integrity.  
In this case, I did NOT get any feedback that helped me.  
To just randomly assign points to answers that were not helpful is counter productive, especially to paying customers.

Signed,
A Paying Customer
0
 
LVL 108

Expert Comment

by:Ray Paseur
Comment Utility
@pmsguy: You asked a reasonable question, but we can't help you without knowing a little more about what you're trying to do, and that's why we need your answers to our questions.  If we can get those answers we might be able to help you make some progress.  BTW it is irrelevant that the domains are on the same server, and the information sharing will probably not be possible in the standard PHP session.  But it can be done with cookies and some custom code.

Please give us an example of what you mean by "symbolic links on the server."

Are you familiar with how doubleclick works?

Thanks, ~Ray (an unpaid volunteer)
0
 

Author Comment

by:pmsguy
Comment Utility
Ray,

I truly do appreciate your passion to answer questions.  As a paying customer I do need to get expedited time sensitive answers to mission critical rapid application development request from my boss.  Therefore, to have a mix of paying customers and volunteers  "producing revenue for Experts Exchange" sometimes becomes a conundrum.

Setting up symbolic links and configuring apache accordingly allows domains to share session variables.  However, when I do this the symbolic link url becomes www.mysite.com/link/siteA and all my javascript AJAX scenarios fail to work due to cross domain issues because the code is expecting the url to be www.siteA.com.

0
 

Author Comment

by:pmsguy
Comment Utility
EE Admin,


Enough already with you trying to explain to me what professional courtesy is.

I am canceling my account because of Experts-Exchange's ridiculous badgering about protocol to reply to this question.

Yes - I am a paying customer.  If I feel a question I have has exhausted its purpose then I should have a right to delete this question if I feel I did not get any useful answers.  

It has become apparent to me, a PAYING customer, that Experts-Exchange 'uses' volunteers to produce revenue without the business professionalism to realize that the paying customer has different needs.



0
 
LVL 10

Expert Comment

by:TekServer
Comment Utility
Just out of curiosity, pmsguy, could you explain why the cookie solution won't work for you, or why you refuse to give Ray any feedback on your symbolic links requirement?

I fail to see the point of being a "paying" customer, and then refusing to interact with the people that are trying to help you.

And something to consider:  you pay for the right to ask questions with money.  We pay for the same right with our time.  Your implication that your money is more valuable than our time is frankly insulting.
0
 
LVL 30

Expert Comment

by:captain
Comment Utility
I second your statement TS.

pmsguy, considering that you have been advised in the past to respond to answers in you thread, you can hardly be surprised about the statements made in here.

Considering further that you asked 180+ complex questions in the past 3 years, which were answered by volunteers and which helped you perform your task at your workplace, is hardly low value for money.

The fact that you now throw the 'I pay for this' gauntlet around, will not help you to get more from EE. The fact that you only respond in anger when you are asked to do what is the simplest thing any community member, shows that you are not aware of what EE provides to you and only reiterates your disrespect to us, the volunteers.
The fact that you threaten to cancel the account as your idea of remedy only paints a poor and bitter picture of how you attempt to solve problems yourself, which is ironic considering you complain about our problem solving skills.

I suggest you take your attitude and spread it out on a table in front of you. Then have a long hard look at it and wonder if you would like to be at the receiving end if you were confronted with such.

If as a result you consider your posts here appropriate then you may never get the principle behind EE and maybe your money is ill-spent and you should look for help elsewhere.

Respectfully
capt.
0
 
LVL 16

Expert Comment

by:CWS (haripriya)
Comment Utility
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Introduction HyperText Transfer Protocol (http://www.ietf.org/rfc/rfc2616.txt) or "HTTP" is the underpinning of internet communication.  As a teacher of web development I have heard many questions, mostly from my younger students who have come to t…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now