5 Replies Latest reply on Oct 27, 2011 10:42 AM by insuractive

    cfcookie help

    RichieWhite Level 1

      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.

        • 1. Re: cfcookie help
          Owain North Level 4

          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.

          • 2. Re: cfcookie help
            12Robots Level 4

            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.



            • 3. Re: cfcookie help
              RichieWhite Level 1

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

              • 4. Re: cfcookie help
                12Robots Level 4

                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.



                • 5. Re: cfcookie help
                  insuractive Level 3

                  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.