I would like to create a bookmarklet that can delete all cookies on the site using javascript.
While checking the browser console,
alert(document.cookie);
I was able to check which cookies exist using , but I am having trouble deleting them.
document.cookie="name=; max-age=0";
document.cookie="name=;expires=Fri, 31 Dec 999 23:59:59 GMT";
I understand that I should use these codes, but I can't execute them well.
I also don't know how to delete all cookies.
I would appreciate it if someone could tell me.
I just searched by keyword, but I found the following example for deleting all cookies.
Perform the deletion of javascript cookies
If you want to delete all cookies, you can do the following:
const clearAllCookies=()=>
document.cookie.split(';').forEach(cookie=> document.cookie=cookie.replace(/^+/, ').replace(/=.*/,`=;max-age=${0};`));
clearAllCookies();
© 2024 OneMinuteCode. All rights reserved.