I have searched various articles and links for deleting cookie using javascipt, but it seems the javascript not working. I used the below code for setting cookie value using javascript -
var now = new Date();
var time = now.getTime();
time += 3600 * 1000;
now.setTime(time);
document.cookie="name=" + $scope.user.name;
document.cookie="email=" + $scope.user.email;
document.cookie ="expires=" + now.toGMTString();
and then while trying to remove the cookie used the below code as in the link w3 schools-
document.cookie = "name= ;email= ;expires=Thu, 01 Jan 1970 00:00:00 GMT";
but nothing seems to work. the cookie is still present. I tried setting the cookie this way also -
document.cookie="name=" + $scope.user.name+";email=" + $scope.user.email+";expires=" + now.toGMTString();
and then again used the same delete operation but cookie iis not getting deleted. What is the problem. I can see that both ways of assigning cookie value is different but the cookie shouls be deleted which is not happening. I checked the results on chromium
Version 50.0.2661.102 Ubuntu 16.04 (64-bit)
and on opera
Version: 37.0.2178.32
in both cases cookie is not getting deleted. One more information is I am including these two codes in two different API calls.