CodeIgniter Forums

Full Version: How to set cookie ONLY for my domain, except subdomains
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]Mareshal[/eluser]
When using ySLow I found this: http://developer.yahoo.com/performance/r...ookie_free

They recommend us to use another domain, or a subdomain to server static content. I was wondering if this code affect static.my-domain.com? I want to set cookie for main domain, but impossible to read from subdomains.

Code:
$config['cookie_prefix']    = "";
$config['cookie_domain']    = ".my-domain.com";
$config['cookie_path']        = "/";

El Forum

[eluser]brianw1975[/eluser]
from http://content.websitegear.com/article/s...n_tips.htm


Quote:If you use cookies in your website, a cookie set from a subdomain
cannot be read from the main domain and vice versa because of the security
association feature tied to the domain which set it. This is also true for
session cookies, where, if the user is logged in on the main site, and
then moves to a subdomain, the subdomain site will not be able to access the
same session cookie, and will assign a new session (hence forcing the user
to login again). However, session persistence
across subdomains can be maintained by implementing URL rewriting instead
of session cookies.

El Forum

[eluser]Mareshal[/eluser]
thank you

El Forum

[eluser]wabu[/eluser]
Also check out the 'domain' parameter description here:

http://us.php.net/manual/en/function.setcookie.php