views:

87

answers:

1

I have implemented single sign on multiple sub domains like:

www.abc.com my.abc.com support.com

using cookies or called session cookies(it will expire as browsers close).

syntax: setcookie("VARIABLE_NAME", VALUE , 0, '/' , '.domain.com');

parameter are name of cookie variable name , value , time of cookie expire(zero means it will destroy on browser close), path , domainname( start from dot so that it will available to all its sub domains)

Check on subdomains if this cookies is set. if set get the value decode it and check in database.

I would like to ask this there any other way to do that.

Thanks

A: 

You can use sessions, but I think you need to set a cookie anyway to have the session across the different sub-domains. I also had to set a session name to achieve that on a site I made:

$session_name = session_name("some_domain");
session_set_cookie_params(0, '/', '.some_domain.com');
session_start();
jeroen
Thanks, as per my knowledge session is not stay same on all domains
neverSayNo
If you use a session name and a session cookie it works.
jeroen
Remember that this will only make the session cookie available to multiple subdomains. You haven't said whether the servers running the subdomains all have access to the same database, so there's no guarantee the session data will be transferrable
Gareth