Dear Old-Timers, You CAN put cfcookie and cflocation on the same page

Every once-in-a-while I still see/hear people perpetuating the false statement that in ColdFusion you cannot put CFCOOKIE and CFLOCATION on the same page because the cookie will not get set due to the relocation. I even saw one today.

This is FALSE

A long, long, long, long time ago, this was true. But for the last 10 YEARS it has not been. This behavior was changed in CF6 (2002, I think).

So all you old-timers who are still spreading this falsity, knock it off.



Reference: CFWACK 7 Page 1008

Adam Cameron's Gravatar I saw the post you were talking about, Jason: good reaction. I have to say I encountered much the same thing only about six months ago. It's amazing how strongly these "problems" stick, once they're established. I dunno what the solution is (other than ranty blog posts like yours, I mean!)

# Posted By Adam Cameron | 8/31/12 5:30 PM
Nathan Mische's Gravatar So this isn't entirely correct. If you call cfcookie before cflocation it will work, however if you call cflocation before cfcookie it will not. cflocation flushes the response buffer so once you use that tag you can no longer add response headers with tags like cfcookie or cfheader etc.
# Posted By Nathan Mische | 9/4/12 9:05 PM
Jason's Gravatar @Nathan,

Thanks for that clarification. It never occurred to me to think anyone would ever expect that to work based on what I said. But, of course, you are right. I would not expect any code on the page to do anything after a cflocation, so I didn't think to point that out.
# Posted By Jason | 9/4/12 9:13 PM
Nathan Mische's Gravatar Yeah, I only pointed it out because I have seen it trip folks up and I've actually heard someone say, "I thought you could use now use cflocation and cfcookie on the same page."
# Posted By Nathan Mische | 9/4/12 10:05 PM
Adam Cameron's Gravatar Hi Jason / Nathan:
From the "Useless Information Dept". I've been able to demonstrate setting a cookie *after* a CFLOCATION call: It relies on a bug in CF9.0.1 though.


# Posted By Adam Cameron | 9/5/12 10:40 AM
Adam Cameron's Gravatar Hey Jason, your blog won't let me us a plus-addressed email. It's nae bother, but thought I'd mention it to you.


# Posted By Adam Cameron | 9/5/12 10:44 AM
henry's Gravatar It is so unbelievable to get these things here to generate the favorites list in edge browser at and we could get our favorites.
# Posted By henry | 3/18/18 3:25 AM
BlogCFC was created by Raymond Camden. This blog is running version 5.9.1. Contact Blog Owner