-
1. Re: How to kill a coldfusion cookie??
Owain North Jul 13, 2011 1:30 PM (in response to lovewebdev)When you say it "remains", do you mean the cookie physically stays on the client PC, or you can still reference the variable in the COOKIE scope?
From the docs: "deletes cookie from client cookie.txt file (but does not delete the corresponding variable the Cookie scope of the active page)."
-
2. Re: How to kill a coldfusion cookie??
lovewebdev Jul 13, 2011 6:12 PM (in response to Owain North)Yes it was still available in scope.
But once I added the domain attribute it worked. Weird. I've never used that before, not sure why it was necessary now. It's all on the same domain.
-
3. Re: How to kill a coldfusion cookie??
Owain North Jul 13, 2011 11:56 PM (in response to lovewebdev)If you're using domain cookies then you'll need to use it here too. I.e. the domain of the cookie you're deleting will need to match up exactly with the CFCOOKIE delete statement.
-
4. Re: How to kill a coldfusion cookie??
saurav Pandit Jul 14, 2011 1:07 AM (in response to lovewebdev)You can use structDelete(cookie,"ckwhatever",true) to clear the cookie structure.
-
5. Re: How to kill a coldfusion cookie??
Owain North Jul 14, 2011 1:11 AM (in response to saurav Pandit)True, but that won't remove the cookie from the user's browser, so the variable will come back on the next request.
-
6. Re: How to kill a coldfusion cookie??
lovewebdev Jul 14, 2011 5:44 AM (in response to lovewebdev)It amazes me that coldfusion has no native way to truly just get rid of a cookie you created from the computer and from the page.
-
7. Re: How to kill a coldfusion cookie??
Owain North Jul 14, 2011 5:46 AM (in response to lovewebdev)It does, you just did it?
-
8. Re: How to kill a coldfusion cookie??
saurav Pandit Jul 14, 2011 6:40 AM (in response to Owain North)To test wheather we can delete the cookie variable or not i have performed the following steps.
Page Name:setcookie.cfm
Note:I am setting cookie in this page.
Code:<cfcookie name="mytestcookie" value="testvalue" expires="never">
<cfdump var="#cookie#">
<a href="killcookie.cfm">kill</a>
Output:
killstruct
MYTESTCOOKIE testvalue Page Name:killcookie.cfm
Note:I am deleting and viewing cookie in this page.
Code:<!--- check wheather cookie exist or not --->
<cfdump var="#cookie#"><br>
<!--- here i am going to delete cookie --->
deleting cookie<br>
<cfcookie name="mytestcookie" expires="#now()#">
<!--- dumping after deleting --->
<cfdump var="#cookie#">
<a href="result.cfm">result</a>
output:
struct MYTESTCOOKIE testvalue
deleting cookie
struct MYTESTCOOKIE [empty string] Page Name:result.cfm
Note: See wheather cookie deleted or notCode:<cfdump var="#cookie#">
Output:
struct [empty] I think after setting expires attr in cfcookie tag the cookie variable is not getting deleted in that page.
-
9. Re: How to kill a coldfusion cookie??
Owain North Jul 14, 2011 6:44 AM (in response to saurav Pandit)I think after setting expires attr in cfcookie tag the cookie variable is not getting deleted in that page.
Which is a bit like what I quoted earlier from the docs:
"deletes cookie from client cookie.txt file (but does not delete the corresponding variable the Cookie scope of the active page)."
-
10. Re: How to kill a coldfusion cookie??
saurav Pandit Jul 14, 2011 7:16 AM (in response to Owain North)yes you are right. I just explained.
-
11. Re: How to kill a coldfusion cookie??
idesdema Aug 17, 2011 6:14 AM (in response to lovewebdev)I am experiencing issues with cookie killing as well so I read through this post. I tried to utilize the domain attribute and that didn't make a difference. I cannot remove my cookie from the local pc. Frustrating. I never used to have problems with this and it seems to work just fine in Firefox. I am currently experiencing the problem using IE 7 (go figure).
The cookie is set like this in the Application.cfm
<cfcookie domain=www.mydomain.com name="mycookie" value="testing" expires="Never">
Here is my cookie removal code. When a user clicks "Logout" on my site they get directed to logout.cfm which contains the code below...
<cfcookie domain=www.mydomain.com name="mycookie" value="" expires="NOW">
<cfset delete_cookie=StructDelete(cookie,"mycookie")>
<cflogout>
<cflocation url="home.cfm">
-
12. Re: How to kill a coldfusion cookie??
12Robots Aug 17, 2011 7:07 AM (in response to idesdema)What version of ColdFusion are you using?
Would it be possible for you to capture and post the request and response headers for the cookie set and cookie kill?
-
13. Re: How to kill a coldfusion cookie??
idesdema Aug 17, 2011 7:40 AM (in response to 12Robots)Version: cf9
I will attempt to do that but am not sure how. Firebug? If firebug, how specifically.
Thx
-
14. Re: How to kill a coldfusion cookie??
12Robots Aug 17, 2011 9:18 AM (in response to idesdema)I would use the firefox plugin called HTTP Live Header. It is great for that kind of stuff
-
15. Re: How to kill a coldfusion cookie??
allenerb Aug 31, 2012 6:48 AM (in response to idesdema)I know this is an older thread, but it's probably going to be helpful for others reading. In reply #11 above, the last line is a <cflocation> - this will essentially ignore any cookie changes made on the page. You'll either need to do a cfheader or a javascript location.href to keep your cookie changes in place.
-
16. Re: How to kill a coldfusion cookie??
12Robots Aug 31, 2012 7:33 AM (in response to allenerb)Sorry to bust your bubble, but that cfcookie/cflocation behavior you are talking about was fixed something like 10 years ago (CF6, I believe). You've been able to put the two on the same page for a Loooooong time. Go ahead and try it.
Update: Here is the page in the CFWACK 7 to back that up.
CFWACK 7 Page 1008
jason
-
17. Re: How to kill a coldfusion cookie??
allenerb Aug 31, 2012 7:49 AM (in response to 12Robots)Thanks for the smart-@ss reply (bust my bubble). I'll check it out. I know I'd had major headaches in the past regarding this so I posted. My bad.
-
18. Re: How to kill a coldfusion cookie??
idesdema Aug 31, 2012 8:37 AM (in response to allenerb)Cflocation hasn't undine cookie changes for me but I'll go check again.
Sent from my iPhone
-
19. Re: How to kill a coldfusion cookie??
12Robots Aug 31, 2012 10:31 AM (in response to idesdema)There's no need to check again. Like I said, that behavior no longer exists.
jason
-
20. Re: How to kill a coldfusion cookie??
RonGruner Mar 29, 2013 6:27 AM (in response to lovewebdev)I too have had problems resetting cookies on various browsers even with CF 9. What I've found seems to work every time is to delete the cookie, and then reset it, for example:
<!--- THIS SEQUENCE WORKS RELIABLY --->
<cfset delete_cookie=StructDelete(cookie,"member_ID")>
<cfcookie name="member_ID" value="0" domain=".phenom.aero" expires="never">
Simply resetting or expiring the cookie does not work reliably, for example:
<!--- NONE OF THESE WORK RELIABLY --->
<cfcookie name="member_ID" value="0" domain=".phenom.aero" expires="never">
<cfset cookie.member_ID = 0>
<cfcookie name="member_ID" value="0" domain=".phenom.aero" expires="now">
Can anybody tell me why? Am I missing something really simple here?
-
21. Re: How to kill a coldfusion cookie??
Joe Bigler Jun 14, 2013 8:15 AM (in response to RonGruner)I just got this to work in an older version of Coldfusion(5). We will be migrating soon. Does this work in your version?
<cfif IsDefined("Cookie.YourCookieName")>
<cfcookie name="YourCookieName" value = "#Now()#" Expires="now" domain=".YourDomainName.com">
<cfset delete_cookie=StructDelete(cookie,"YourCookieName")>
<cfoutput>"Cookie is Gone"</cfoutput>
<cfabort>
<cfelse>
<cfcookie name="YourCookieName" value = "#Now()#" Expires="never" domain=".YourDomainName.com">
<cfoutput>"Cookie exists"</cfoutput>
<cfabort>
</cfif>
I put this after <CFAPPlication> with
<cfapplication
name = "YourAPPName"
clientmanagement="yes"
sessionmanagement="yes"
setclientcookies="yes"
sessiontimeout="#CreateTimeSpan(0, 0, 30, 0)#"
applicationtimeout="#CreateTimeSpan(0, 0, 30, 0)#" clientstorage="Registry"
>
To test it, I reload the page. It alternates between the "Cookie is Gone" and "Cookie exists". Let me know if that works for you.



