Quantcast
Channel: Geekstrick
Viewing all articles
Browse latest Browse all 10

How to create a cookie using JavaScript?

$
0
0

The simplest way to create a cookie is to assign a string value to the document.cookie object, for example- document.cookie = "key1 = value1; key2 = value2; expires = date"; // Example var now = new Date(); now.setTime(now.getTime() + 1 * 3600 * 1000); //set cookies to expire in 1 hour document.cookie = `${key} = […]

The post How to create a cookie using JavaScript? appeared first on Geekstrick.


Viewing all articles
Browse latest Browse all 10

Trending Articles