Now check your cookies folder to see if the cookie was created. Alternatively, write code to read the cookie.
Note: If the cookie wasn't created, check the expiry date — it needs to be a date in the future.
You can update this value by using the same code with a different value. If you want to add a second value, simply use a different variable name (for example
You simply reference the cookie using
document.cookie. The only problem with the above code is that it outputs the equals sign and everything before it (eg,
myContents=). To stop this from happening, try the following code:
To delete a cookie, you can use the same code you used to create it but this time, set the expiry date in the past:
getDate() function to set the date at a date in the future (say, 6 months), creating a function for setting and naming your cookies etc.
However, there are always going to be security implications with any technology that stores data, and cookies are no exception.