Skip to content

Instantly share code, notes, and snippets.

@johny
Created September 26, 2019 12:08
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 johny/b6ae722761e6fbe4a73fcd3303a9bc33 to your computer and use it in GitHub Desktop.
Save johny/b6ae722761e6fbe4a73fcd3303a9bc33 to your computer and use it in GitHub Desktop.
Short prompt to set cookie and value
@johny
Copy link
Author

johny commented Sep 26, 2019

Minified version:

javascript:function cookiePrompt(){var cookieName=prompt("Enter cookie name");var cookieValue=prompt("Enter cookie value");if(cookieName&&cookieValue){var expiryDate=new Date();expiryDate.setMonth(expiryDate.getMonth()+1);var cookieString=cookieName+"="+cookieValue+"; expires="+expiryDate.toUTCString()+"; path=/";document.cookie=cookieString;alert("Cookie set: "+cookieString);}}cookiePrompt();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment