Skip to main content
May 14, 2013
Question

CFCookie and domains

  • May 14, 2013
  • 1 reply
  • 576 views

My cfcookies are only good for "domain.com" and if a user goes to "www.domain.com" the cookie is not valid.  Any ideas on how I can make the cookie valid for the entire domain? 

I have entered the domain as ".domain.com" in the cfcookie tag.  Coldfusion version is 8.

Thanks!

Mike

    This topic has been closed for replies.

    1 reply

    BKBK
    Community Expert
    Community Expert
    May 17, 2013

    It may de interpreted that domain.com and www.domain.com are different. Leave out the domain attribute. Then Coldfusion will set the cookie in the current domain, whatever that is. You could alternatively, and as a last resort, use Javascipt to set the cookie.

    May 17, 2013

    Thanks for the input BKBK...you are exactly right, it was interpreting the domain and www.domain differently.  The cfcookie has been setting for years with no domain attribute and suddenly this problem came up. 

    I have tried it with and without the domain attr and it still will not include the "www" inside the domain like it should. 

    I solved the problem (so far so good at least) with a url redirect that sends all www requests to the regular domain name.

    ~Mike