I’m going to have to use data on more than one domain. That data need to be stored, so sessions are out. I guess cookies are out too, since it’s a security issue to share one cookie across multiple domains.
How would you approach an application that has to deal with this problem?
You could easily share a database table between multiple domains for something like user accounts and then have individual domain specific tables as required.
In SQL you can prefix a table select with a database, ie.
SELECT *
FROM site_a.products
JOIN site_b.users ON site_a.products.user_id = site_b.users.id
btw i’m assuming you mean multiple domains on the same server, which would give you the best results, however you could also have a shared database server that each domain server connects to.
im no expert on cookies but you might run into browser issues trying to set 3rd party cookies in browsers with high security settings.
Is there no way to query somesite.com with information that you have available on anothersite.com? If anothersite.com has some shared identifier then you could potentially have a script on somesite.com which would return the data that you want. You could use file_get_contents() for this with some query string parameters. A bit like a bare bones API I guess.
I think it might be helpful if you explain how you got yourself into this situation!
You could serialize the shared data within a database that both sites can talk to then have a common token that link this data to a user or function or however you need to link the data.
One other option is to have siteA implement a JSON service and have siteB connect to siteA’s JSON service, get the needed data, and parse it. A JSON service could also be implemented on SiteB so siteA could get data from there. This will effectively pass the data between sites.
Whoops Cups yes I meant to put JSONP thanks for clearing that up! Yes a regular JSON request would fail due to the cross origin problem but JSONP will overcome this.