Copy link to clipboard
Copied
If I set a cookie from www.mydomain.com and set a cookie with the same name at mydomain.com - it will show as 2 different cookies (one for each site).
How can I let coldfusion know those are the same locations and not 2 different cookies? As it is now, my site works if they use the www. but doesn't work without the www.
Thanks for your help.
Copy link to clipboard
Copied
You need to use the DOMAIN attribute of the CFCOOKIE tag to set the domain you want to set the cookie for - make sure it's always set for mydomain.com regardless of the URL they're browsing to and it'll be available at all times.
You might want to consider just using a rewrite engine to redirect people from the non-www site whenever they browse it if it's causing a problem.
Copy link to clipboard
Copied
Actually, to do this properly you need to set the cookie with domain=".mydomain.com". Notice the dot (.) at the beginning of the value. This tells the browser to use that cookie for the domain and every host/subdomain of that domain.
Jason
Copy link to clipboard
Copied
What will that do to my local testing? I'm using cookies for logins.
Copy link to clipboard
Copied
If your local testing domain is local.mydomain.com then it will work fine. If your local testing is some other domain (like localhost) then it will not work.
I recommend trying to make your local domain something like local.mydomain.com. It's quite easy t do if you are using Apache or IIS.
Jason
Copy link to clipboard
Copied
Otherwise, you can always resort to creating an environmental-aware application variable to store the domain string based on what environment (local, production) the code is executing in.