-2

I am currently developing my private site which consists out of many subdomains (for news/ blog etc).

So i thought of the idea that users can login through login.domain.com. After that they should be logged in everywhere. The only problem is that im still struggling with the idea of an SSO. I dont understand how blog.domain.com can understand if the client logged in at login.domain.com since cookies/sessions are set per domain.

Can someone briefly explain the idea (with maybe some PHP examples?). Or are there some good PHP librarys that make SSO possible (i've tried one but failed using it)?

1
  • Bear in mind that cookies can be set for the whole .domain.com domain, so they'll get passed to each subdomain, too.
    – andrewsi
    Aug 7, 2012 at 19:04

1 Answer 1

2

If the session is only going to be shared on subdomains, you can set the session cookie to be valid on your entire domain.

http://php.net/manual/en/function.session-set-cookie-params.php

For example:

session_set_cookie_params(0, "/", ".example.com");
0

Not the answer you're looking for? Browse other questions tagged or ask your own question.