In my Javascript I have a cookie with several names and values:
"Token=23432112233299; sessionuid=abce32343234"
From server when I download a file a Add a Cookie so the new document cookie will look:
"Token=23432112233299; sessionuid=abce32343234; fileDownload=true"
How can I remove the fileDownload
name and value from cookie
and update document.cookie?
UPDATE:
This is the code I have done so far but its not working:
if (document.cookie.indexOf("fileDownload=true;") != -1) {
document.cookie = document.cookie.replace("fileDownload=true;", "");
} else {
document.cookie = document.cookie.replace("fileDownload=true", "");
}
Change the expires parameter to the elapsed date.
document.cookie = 'fileDownload = ; expires=-1';
var cookieData = "fileDownload=; path=/" +"; expires=" + new Date(0).toUTCString() + ";";
if (null) cookieData += " domain=null;";
document.cookie = cookieData;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.