Category: JavaScript Cookies
-
Deleting a Cookie in JavaScript
In the previous section, we learned the different ways to set and update a cookie in JavaScript. Apart from that, JavaScript also allows us to delete a cookie. Here, we see all the possible ways to delete a cookie. Different ways to delete a Cookie These are the following ways to delete a cookie: Examples…
-
Cookie with multiple Name-Value pairs
In JavaScript, a cookie can contain only a single name-value pair. However, to store more than one name-value pair, we can use the following approach: – Examples to Store Name-Value pair in a Cookie Example 1 Let’s see an example to check whether a cookie contains more than one name-value pair. Output: On clicking Get Cookie button,…
-
Cookie Attributes
JavaScript provides some optional attributes that enhance the functionality of cookies. Here, is the list of some attributes with their description. Attributes Description expires It maintains the state of a cookie up to the specified date and time. max-age It maintains the state of a cookie up to the specified time. Here, time is given…