Share Data Between Two Domains


Here is the situation: I have a website which is not secured (not https) and available on different domains depending on the country (.fr, .ca, .com, .es, etc). All of these domains have one page where a user chooses an option. Then later on, the user has to go on a buy.php page which is located on our secure domain ( That page must be able to have access to the option that the user has chosen.

Furthermore, if the user goes directly to the buy.php page, it can still choose the option and when the user goes back to its original non-secured domain, the non-secured domain must also be able to read this option.

We have, for the moment, a cookie but of course it cannot be read on both domains.

How can I do this?

Thank you :)

If you only have one database, and I assume you won’t maintain a separate one for each domain, you could simply use that as a storage medium and read the value per user from each domain.

I recently ran into a very similar situation.

We have a secured members area on a separate virtual host within the same server, but since php uses files out of the box for sessions these are limited to host settings.

We discovered memcached would make a great tool to carry sessions across domains. It’s especially helpful as well for caching data, images or whatever else you need to cache, but that’s another topic.

Don’t know if you’ve already solved this but look into it, once I installed the memcached server it took only 3 lines of code and about 30 seconds to share sessions across every host and sub-domain on my site.

Hope it’s useful.


Sponsor our Newsletter | Privacy Policy | Terms of Service