Skip to main content
Participating Frequently
October 25, 2011
Question

cfcookie help

  • October 25, 2011
  • 1 reply
  • 1300 views

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.

    This topic has been closed for replies.

    1 reply

    Owainnorth
    Inspiring
    October 25, 2011

    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.

    12Robots
    Participating Frequently
    October 25, 2011

    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

    Participating Frequently
    October 25, 2011

    What will that do to my local testing? I'm using cookies for logins.