Creating a Cookie using jQuery
In one of my projects, I was tasked to create a cookie (no, not the chocolate chip dough, but a browser cookie), and I had to do it using jQuery, a commonly used JavaScript library. It can be done using plain old JavaScript, of course, but life is so much better with jQuery! By definition, a browser cookie is a text file created by a web browser for every unique website or domain. The cookie can only be accessed on the same domain where it was originally created. To be able to create a cookie using jQuery, you need to include a plug-in that can be downloaded from GitHub . Everything is already explained on the GitHub page, and the code is not very complicated. Perhaps, a few watch-outs would be: Differentiating between a session cookie and an expiring cookie. A session cookie is only valid until the user closes the web browser. An expiring cookie only gets removed after a specified number of days. Note: the unit of measure for the expires parameter is days . The path p...