Within my JavaScript code, I am working with a cookie that contains multiple names and values:
"Token=23432112233299; sessionuid=abce32343234"
When I download a file from the server, a new cookie is added to the document, resulting in the following cookie:
"Token=23432112233299; sessionuid=abce32343234; fileDownload=true"
I need to find a way to remove the fileDownload
name and value from the cookie
and update the document.cookie accordingly.
UPDATE:
Here's the code I have attempted so far, but it doesn't seem to be functioning properly:
if (document.cookie.indexOf("fileDownload=true;") != -1) {
document.cookie = document.cookie.replace("fileDownload=true;", "");
} else {
document.cookie = document.cookie.replace("fileDownload=true", "");
}