1. Home
  2. Javascript
  3. Set cookie for a year

Set a cookie with one year expiry date.

#javascript#cookie
document.cookie = `cookie_name=${cookie_value}; expires=${new Date(new Date().getTime()+1000*60*60*24*365).toGMTString()}; path=/`;
copy
Full Javascript cheatsheet