Single Sign-On (SSO) with and without subdomains
Posted in catalyst, authentication, singlesignon Sun, 17 Jun 2007 01:06:00 GMT
If you are running a site without a subdomain, e.g. http://dev411.com and need to maintain cookie-based sessions across other server names with subdomains, e.g. blog.dev411.com and wiki.dev411.com, you will need to customize your session cookies.
To have your session cookie be used across multiple subdomains, set a wildcard domain which starts with a dot followed by the base domain name, e.g. ".dev411.com", which will make it qualify for all subdomains of dev411.com. This, however, will not work for http://dev411.com where there is no subdomain.
The have the same session used for http://dev411.com, set a second session cookie without domain. This way the domain-less cookie will be used for http://dev411.com and the wildcard domain cookie will be used for all subdomains.
Catalyst 5.7007 will only set one cookie per cookie name, however, this solution works best when you can set both cookies with the same name but different cookie domains. I put together a quick patch for Catalyst::Engine to allow multiple cookies when the cookie value is set to an arrayref.
Hi, i’m setting a cookie for my site using the function below:
PHP Code: $cookieURL = ”.mysite.com” ; $duration= 11060 + time(); // for 10 minutes setcookie(‘cookie1’,$duration,$duration,$cookiePath,$cookieURL); $value=$_COOKIE[‘cookie1’]; echo “The value: ”.$value; }
However, it only works in mozilla.
I also tried to playing with the $duration, if i out the $duration to time()+606024 , the cookie is working in IE…
Why is it when I put the $duration=time()+60*60, it is not working in IE?
Do youn know why?