Is my function of creating a cookie correct? How do I delete the cookie at the beginning of my program? is there a simple coding?
function createCookie(name,value,days)
function setCookie(c_name,value,1) { document.cookie = c_name + "=" +escape(value); } setCookie('cookie_name',mac); function eraseCookie(c_name) { createCookie(cookie_name,"",-1); }
To delete an individual cookie, select the cookie in the list, and click “Remove Selected”. To delete all cookies for a specific website, select the website folder and click “Remove Selected”.
Delete cookies from a specific siteUnder Cookies and data stored, select Manage and delete cookies and site data > See all cookies and site data and search for the site whose cookies you want to delete. Select the down arrow to the right of the site whose cookies you want to delete and select Delete .
In Chrome, click the vertical ellipsis button in the upper right corner. Select "More tools", then "Clear browsing data". Or, you can use the shortcut of pressing the Ctrl + Shift + Delete keys to bring up the same menu. This keyboard shortcut works on Chrome, Firefox, Edge, and Internet Explorer.
Try this:
function delete_cookie( name, path, domain ) { if( get_cookie( name ) ) { document.cookie = name + "=" + ((path) ? ";path="+path:"")+ ((domain)?";domain="+domain:"") + ";expires=Thu, 01 Jan 1970 00:00:01 GMT"; } }
You can define get_cookie()
like this:
function get_cookie(name){ return document.cookie.split(';').some(c => { return c.trim().startsWith(name + '='); }); }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With