Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2010-11-10
18
Medium Priority
?
619 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
18 Comments
 
LVL 111

Accepted Solution

by:
Ray Paseur earned 672 total points
ID: 34105713
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 111

Expert Comment

by:Ray Paseur
ID: 34105720
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 664 total points
ID: 34107356
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
Supports up to 4K resolution!

The VS192 2-Port 4K DisplayPort Splitter is perfect for anyone who needs to send one source of DisplayPort high definition video to two or four DisplayPort displays. The VS192 can split and also expand DisplayPort audio/video signal on two or four DisplayPort monitors.

 
LVL 111

Expert Comment

by:Ray Paseur
ID: 34107624
@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 664 total points
ID: 34110278
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
ID: 34218799
I need to find out how to do this using symbolic links on the server.
0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 34218872
Please give us an example of what you mean by "symbolic links on the server."
0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 34360778
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
ID: 34368624
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 111

Expert Comment

by:Ray Paseur
ID: 34368661
@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
ID: 34368737
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
ID: 34389986
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
ID: 35394061
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 31

Expert Comment

by:captain
ID: 35395362
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)
ID: 36042309
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

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to count occurrences of each item in an array.
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.

722 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