Previously, I had a misconception that we can only delete a cookie from ColdFusion by using CFCOOKIE tag only. But, during experimenting with ColdFusion cookie, I just got to know that even using function "structDelete" we can alos delete a cookie.
Let's see how exactly:
I had written the above CF code to test.
- When first I run this page, I see two cookie variables - CFID and CFTOKEN. You can see the image below.
- Refresh the page again, you will see the target cookie is deleted. As shown below.
Question: What exactly ColdFusion does to delete a cookie from browser?
- Set the cookie "X" by following the above steps.
- Pass url parameter "delByTag = 1" and run the page, you can see the cookie "X" is empty in seond dump after refreshing the page you will see no cookie "X" in dump. If we will notice the HTTP request for cookie delete then we will find the following screen shot.
If you again set the cookie and for delete don't use "delByTag = 1", so it will use struct delete and in that case if we will see the HTTP response as shown below. Here, we will see the a same thing in resopnse to delete the cookie.