1. Home
  2. Javascript
  3. Set cookie

Create cookie by passing a cookie name, value, expiry date and path to witch the cookie belongs.

#javascript#cookie
document.cookie = "simpleCookie=Cookie value"; // Simple cookie
document.cookie = "cookieName=Cookie value; expires=Sun, 15 Jun 2019 23:59:00 UTC; path=/javascript-cheatsheet" // Cookie with an expiry date and a path set
copy
Full Javascript cheatsheet