Skip to content

Instantly share code, notes, and snippets.

@Arieg419
Created September 17, 2017 19:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Arieg419/6a3f731d399432991353789bb7ee392b to your computer and use it in GitHub Desktop.
Save Arieg419/6a3f731d399432991353789bb7ee392b to your computer and use it in GitHub Desktop.
A method for setting cookies in the browser.
const setCookie = (key,val,days_till_expiration) => {
let d = new Date();
d.setTime(d.getTime() + (days_till_expiration*24*60*60*1000));
const expires = "expires=" + d.toGMTString();
document.cookie = key + "=" + val + ";" + expires + ";";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment