Eat the Cookie

Share This Post

In my last couple of posts (‘C is for Cookie‘ and ‘Read Your Fortune…Cookie That Is‘), I spoke about cookies, how they are created and read, but what if you wish to get rid of a cookie? End users can clear out their cookies anytime they wish, but as developers, there might be times when we would like to clear a cookie. How can we accomplish this programmatically?

It is fairly simple…we just have to write a cookie with the name we would like to erase, have the value be blank and a date of -1. This will cause it to be erased. Here is some example code…


[code lang=”js”]
function eraseCookie(name) {
// Erase the specified cookie
// Function calls previous writeCookie function
writeCookie(name, "", -1);

As you can see, I am utilizing the writeCookie() function that I blogged about already in ‘C is for Cookie‘. This is an example of where modality helps us in writing less code.

Now, a couple of questions to ask/keep in mind if we use cookies…

  • Do cookies pose a security threat? Not if used properly. They are plain text. So, as a developer, it is your job to not make them insecure. Do not store sensitive data in them.
  • What if we name a cookie the same as another application names theirs? Does not matter. Cookies are domain specific. So they will each be kept separate. It would only matter if you had two cookies with the same name within your web application.
  • With cookies, do we even need a database? In most cases, yes. Cookies do not replace database functionality. End users can delete their cookies and we should not store sensitive data within them. Plus, by using a back end database, we can perhaps run data analytics/mining on our app data, but that is for another post.
  • What about end users who have disabled cookies? While I believe this is probably rare, it is probably a good practice to test if they are enabled or not. Thankfully, browsers give us the ability to check this. We can run an if test on navigator.cookieEnabled. If this returns false, then cookies are disabled. We can then take whatever actions are appropriate.

Happy Coding!

Clay Hess


More To Explore


Demystifying Scrum User Stories Confirmation: Ensuring Quality and Collaboration

One of the key elements of Scrum is the use of user stories to define the requirements of a system or feature from the perspective of the end user. As teams work through the product backlog, it becomes crucial to confirm the user stories to ensure they meet the desired criteria and are ready for development. In this blog post, we’ll explore the concept of Scrum user stories confirmation and its significance in delivering high-quality products.


The Power of Conversations in Scrum User Stories

At the heart of Scrum lies the concept of user stories, which serve as a means of capturing requirements from the perspective of end-users. However, the true power of user stories lies not just in their written form but also in the conversations that take place around them. In this blog post, we will explore the significance of conversations in Scrum user stories and how they contribute to the success of Agile projects.

Do You Want To Boost Your Business?

drop us a line and keep in touch

Scroll to Top

Need help?

Let's have a chat...


Jump Back In!

Here at Webolution Designs, we love to learn. This includes sharing things we have learned with you. 


Begin Your Learning Journey Today!

Come back inside to continue your learning journey.