0

I have two distinct web applications that are hosted on the same server, and the two web applications are on totally different domains. The web applications will have many users in common though, so I want to share logins between the two applications. In my web applications I set a cookie as the session ID. How can I get the web applications to see the other applications session ID?

In case you guys need more info the server is your standard LAMP server and the applications are using the CakePHP framework.

Thanks in advance!

cyphun
  • 163
  • 3
  • 14
  • Have you thought about setting one of the apps up as an api? and then modifying the Auth component to check the api for a user and the local db for user? – Tim Joyce Jan 07 '13 at 10:04
  • I am not 100% sure what you are saying @TimJoyce, but both applications already use the same user table, so both applications can authenticate using the same information (i.e. user John can login to both sites using his one username and password). I just wanted it to happen automatically without the user having to do anything. – cyphun Jan 07 '13 at 20:35

1 Answers1

1

You can't. Well you can, but strictly speaking a Cookie can only be used on one domain (and all subdomains, depending on Cookie path set in app/config/core.php in the case of your CakePHP app).

CakePHP or no CakePHP, a cookie can't be used across domains. But there is a work around. This is quite common question on SO.. here is a great answer:

How do I use cookies across two different domains?

Community
  • 1
  • 1
Happy
  • 806
  • 4
  • 7
  • I tried using the method explained in that link, but it doesn't work with my setup. – cyphun Jan 09 '13 at 05:25
  • 1
    UPDATE: This wasn't working because I had disabled third party cookies in my browser for testing. So this method would work for my situation if third party cookies were enabled. – cyphun Jan 09 '13 at 05:41