Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function setCookie(name, value, days=0, hours=0, minutes=0) {
- const milliseconds = ((days*24+hours)*60+minutes)*60*1000,
- expire = new Date(Date.now()+milliseconds)
- document.cookie =
- name+'='+value+'; path=/; expires='+expire.toUTCString()
- return value
- }
- function getCookie(name) {
- const matches = document.cookie.match(new RegExp('(?:^|; )'+
- name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g,'\\$1')+'=([^;]*)'));
- return matches? decodeURIComponent(matches[1]) : undefined;
- }
- delCookie = name=> name? setCookie(name,'',-1) :
- document.cookie.split(";").forEach(c=> document.cookie = c.replace(/^ +/,'')
- .replace(/=.*/,"=;expires="+ new Date().toUTCString() +";path=/"))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement