Skip to content

Instantly share code, notes, and snippets.

@pingyen
Last active October 4, 2024 18:42
Show Gist options
  • Save pingyen/498dc2512d84166d8c7f0bc6d3c23d13 to your computer and use it in GitHub Desktop.
Save pingyen/498dc2512d84166d8c7f0bc6d3c23d13 to your computer and use it in GitHub Desktop.
PTT ask/over18 set cookie in JS
document.querySelector('button[name="yes"]').addEventListener('click', e => {
e.preventDefault();
document.cookie = 'over18=1; path=/';
location = document.querySelector('input[name="from"]').value;
}, false);
document.querySelector('button[name="no"]').addEventListener('click', e => {
e.preventDefault();
location = '/';
}, false);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment