Solved

Any way to "share" PHP session variables between two domains?

Posted on 2011-03-23
3
311 Views
Last Modified: 2012-05-11
We have two websites featuring two aspects of our business: metrology and robotics. As these two are related, we have many links between these two sites, and they are designed to work seamlessly - they even look similar.
We don't have any LOG IN forms on either one of the sites, but, we have "quote request" forms for different items. Many times, a customer will fill out their info in one of the forms and request the quote, I would save their contact info in PHP session variables and when they move onto another quote request during the same visit, their contact info is pre-filled in the form.  It is convenient to the customer, but...

but, of course, once they leave one site and go to our other site, the session variables are lost.

Is there any way to retain the session variables values between two sites?
0
Comment
Question by:Erie_Laker
  • 2
3 Comments
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 35202085
No, not without explicitly transferring them.  You would have to read them all and pass them via a POST to the other site.

The other choice is to put all that in a database which you can share between sites.  You would have to come up with another way to track the customer but that's doable.
0
 

Author Comment

by:Erie_Laker
ID: 35301581
@Dave
"The other choice is to put all that in a database which you can share between sites.  You would have to come up with another way to track the customer but that's doable."

Could you please explain how?
0
 
LVL 83

Accepted Solution

by:
Dave Baldwin earned 500 total points
ID: 35301733
You can set up databases like MySQL and MS SQL so they can be accessed from anywhere with a username and password.  I edit the databases on my websites from a page running on the webservers here at home.  The database server(s) is independent from the web servers.

So if you save the original info from either site in the database, you can access it again when your customer goes to the other site.  You would still have to come up with a way to recognize them because cookies and session data don't transfer between sites.  Some kind of login in the original quote form would do.  Note that once it's in the database, it doesn't disappear with the customer and you can access it later if you want to.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
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…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

792 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