SitePoint Sponsor

User Tag List

Results 1 to 11 of 11
  1. #1
    SitePoint Wizard
    Join Date
    Jan 2005
    Location
    blahblahblah
    Posts
    1,447
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How do you handle data shared across multiple domains?

    Hello,

    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?

    Regards.

    -jj.

  2. #2
    SitePoint Wizard wheeler's Avatar
    Join Date
    Mar 2006
    Location
    Gold Coast, Australia
    Posts
    1,369
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What type of data are you talking about?

    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.

    Code:
    SELECT * 
    FROM site_a.products
    JOIN site_b.users ON site_a.products.user_id = site_b.users.id
    Studiotime - Time Management for Web Developers
    to-do's, messages, invoicing, reporting - 30 day free trial!
    Thomas Multimedia Web Development

  3. #3
    SitePoint Wizard wheeler's Avatar
    Join Date
    Mar 2006
    Location
    Gold Coast, Australia
    Posts
    1,369
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.
    Studiotime - Time Management for Web Developers
    to-do's, messages, invoicing, reporting - 30 day free trial!
    Thomas Multimedia Web Development

  4. #4
    SitePoint Wizard
    Join Date
    Jan 2005
    Location
    blahblahblah
    Posts
    1,447
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nope... That would be somesite.com and anothersite.com. Basically, anothersite.com would share data with somesite.com. In other words, somesite.com would need to use data provided by anothersite.com to function properly. Nothing crazy about the data in question, just an id string.

    A shared cookie would just be perfect, but it's not safe security-wise, and a bit painful to implement, is it?

  5. #5
    SitePoint Wizard wheeler's Avatar
    Join Date
    Mar 2006
    Location
    Gold Coast, Australia
    Posts
    1,369
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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!
    Studiotime - Time Management for Web Developers
    to-do's, messages, invoicing, reporting - 30 day free trial!
    Thomas Multimedia Web Development

  6. #6
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    Does the id key you are talking about change depending on the user? Or is it a site-wide key you just need to update periodically?

  7. #7
    Foozle Reducer ServerStorm's Avatar
    Join Date
    Feb 2005
    Location
    Burlington, Canada
    Posts
    2,699
    Mentioned
    89 Post(s)
    Tagged
    6 Thread(s)
    Hi,

    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.

    Steve
    ictus==""

  8. #8
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    @ServerStorm - wouldn't that have to be a JSONP request because of the Cross Origin Resource problem?

  9. #9
    Foozle Reducer ServerStorm's Avatar
    Join Date
    Feb 2005
    Location
    Burlington, Canada
    Posts
    2,699
    Mentioned
    89 Post(s)
    Tagged
    6 Thread(s)
    Quote Originally Posted by Cups View Post
    @ServerStorm - wouldn't that have to be a JSONP request because of the Cross Origin Resource problem?
    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.

    Regards,
    Steve
    ictus==""

  10. #10
    SitePoint Wizard
    Join Date
    Jan 2005
    Location
    blahblahblah
    Posts
    1,447
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Great ideas, will look into that.

  11. #11
    SitePoint Wizard lorenw's Avatar
    Join Date
    Feb 2005
    Location
    was rainy Oregon now sunny Florida
    Posts
    1,101
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Not sure exactly what you are doing but I have two domains that need to maintain shared data and cURL works perfectly.
    What I lack in acuracy I make up for in misteaks


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •