There is no delete function for cookies. You have to set it in the past.
Here's a function to do just that, set a cookie by its name in the past.
function delete_cookie(name) {
document.cookie = name +'=; Path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;';
}
Code language: JavaScript (javascript)
You might also need to add the domain in certain scenarios:
function delete_cookie(name) {
document.cookie = name +'=; Path=/; Domain=.example.com; Expires=Thu, 01 Jan 1970 00:00:01 GMT;';
}
Code language: JavaScript (javascript)