In reality the cookie is set but, when you try to read them, it does not really do out to the users hard drive to see if it is there. Cookies are read as part of the header record which does not get updated with the set statement. Therefore, you have to read a new page or take an action to get a new HTTP header record to be sent. The CFLOCATION does NOT cause this to happen in version prior to CFMX.
There is a pretty good explination of this in the reference Billy sent out today. At least more definitively than anything I have seen in writing before. As an aside, this was always one of the harder concepts for people to grasp when I was teaching CF. From: "Dave Shuck" <[EMAIL PROTECTED]> Date: 2002/11/18 Mon PM 12:21:18 CST To: <[EMAIL PROTECTED]> Subject: RE: Cf cookies Are you doing a CFLOCATION on the page you are setting your cookie? Just a guess, but if so, they are never actually being set. Try using something like: document.location.href='[url]'; rather than CFLOCATION -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] On Behalf Of Ron Mast Sent: Monday, November 18, 2002 11:54 AM To: [EMAIL PROTECTED] Subject: Cf cookies Hi All, I'm trying to set a cookie.looks like this: <cfcookie name="TCCookie" Value="truth" Expires="never"> I want to do the following but I keep coming up with "TCCookie is not defined!" when I ran the above code: <cfif IsDefined("cookie.TCCookie")> TCCookie is defined! <cfelse> TCCookie is not defined! </cfif> I have an application.cfm in my wwwroot: <cfapplication name="colors" sessionmanagement="Yes" sessiontimeout="#CreateTimeSpan(0,0,20,0)#" setclientcookies="Yes"> Does anyone know what I'm doing wrong? Thanks in advance. Ron Mast Truth Hardware Webmaster (507)444-4748Title: Message
Are
you doing a CFLOCATION on the page you are setting your cookie? Just a
guess, but if so, they are never actually being set. Try using something
like:
document.location.href=''; rather than
CFLOCATION
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] On Behalf Of Ron Mast
Sent: Monday, November 18, 2002 11:54 AM
To: [EMAIL PROTECTED]
Subject: Cf cookiesHi All,
I'm trying to set a cookie…looks like this:
<cfcookie name="TCCookie" Value="truth" Expires="never">I want to do the following but I keep coming up with "TCCookie is not defined!" when I ran the above code:
<cfif IsDefined("cookie.TCCookie")>
TCCookie is defined!
<cfelse>
TCCookie is not defined!
</cfif>I have an application.cfm in my wwwroot:
<cfapplication name="colors" sessionmanagement="Yes" sessiontimeout="#CreateTimeSpan(0,0,20,0)#" setclientcookies="Yes">Does anyone know what I'm doing wrong? Thanks in advance.
Ron Mast
Truth Hardware
Webmaster
(507)444-4748
