Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Updating/Deleting Domain Cookies

New Here ,
May 13, 2010 May 13, 2010

I've discovered an issue that apparently stems from case sensitivity with cookies, but I'm not sure exactly where or why this issue is happening; it occurs with CF7 and FF/IE7, so I'm looking to find out whether I'm doing something wrong, given that cookies are not supposed to be case senstive. I wasn't able to find anything definitive on this subject in my searches.

I'm using domain cookies so that they can be shared across 2 sites.

Site 1: WordPress (PHP) site, cookies are set by a custom plugin and have camelCase.

Site 2: CF site, recognizes cookies from site 1 (apparently for this part, CF is case-insensitive for cookie names).

If in the CF site I attempt to update the cookies from the WP site, I end up with 2 sets of cookies: One set still camelCase from the WP site, the other set in ALLCAPS from the CF site (because CF makes the cookie names ALLCAPS regardless of the case you use).

If in the CF site I attempt to delete the cookies from the WP site, the values are set to be blank during the CF page request, but on the next page request, the original camelCase cookie values are restored. I attempted to delete the cookies using cfcookie followed immediately by deleting the cookie names from the cookie struct, to no avail.

To test whether it was a case sensitivity issue, I obtained the cookies from the WP site, edited them to be named with ALLCAPS instead of camelCase; then on the CF site, the cookies were appropriately updated, and I could appropriately delete them, too.

What gives?

- JH

995
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 13, 2010 May 13, 2010

Is it because you're using dot notation (cookie.myCookie), as opposed to bracket notation (cookie["myCookie]).

When using dot notation, the key is capitalised under the hood so as to implement case insensitivity.  Using bracket notation preserves the case.


Note - strangely - have never used cookies for anything, so don't know about their vagaries.  However the above applies for all other scopes / structs in CF.

--
Adam

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 13, 2010 May 13, 2010

CF is reading the camelCase cookies fine using dot notation, so I don't know that dot notation vs bracket notation really applies here. My main issue is being able to update/delete the existing camelCase cookies, which CF just seemingly isn't able to manipulate. I'm certainly no cookie expert, but oddly enough to me it seems like it would be a browser issue since it's allowing 2 cookies of the same name with different cases. That is, if FF is holding a cookie called "thisIsMyCookie" with domain "domain.com", and CF sends FF another "domain.com" cookie called "THISISMYCOOKIE", shouldn't FF be the one to edit or replace the original "thisIsMyCookie" cookie? But if it were the case that it was a browser issue with cookie handling, I'm sure that would have been a glaring issue that countless before me would have picked up on, so I have to assume that the browser behavior is correct.

Is it even possible to manipulate (update/delete) cookies using CF bracket notation, but to maintain the expiration and domain parts of the cookie?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 13, 2010 May 13, 2010

I did a bit of a google (about 30sec) and discovered this is perhaps well-trod ground.

Have a read of this:

http://www.coldfusionjedi.com/index.cfm/2008/4/16/Ask-a-Jedi-Creating-lowercased-cookies-in-ColdFusion

I'm off to raise a bug with Adobe re <cfcookie> turning a cookie name to all caps.  That's just stupid (documented, but stupid).

--

Adam

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 13, 2010 May 13, 2010

Adam take a look at your pms please.

Yannis.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 13, 2010 May 13, 2010
LATEST

I'm not that pre-menstrual sounding am I?  😉

Yep, saw your msg.  Will get back to you tomorrow.

--

Adam

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources