Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
169
rated 0 times [  175] [ 6]  / answers: 1 / hits: 24905  / 11 Years ago, fri, june 7, 2013, 12:00:00

Can I modify document.cookie in the console of Chrome Developer Tools?



My current cookie string was like:



coldcookie=


It seems it just doesn't work if I run this code below:



document.cookie = document.cookie + ; newcookie=something


The document.cookie wouldn't change at all.



Update: I found that if I run:



document.cookie = newcookie


It actually add a newcookie in the cookie string like:



oldcookie=; newcookie


Shouldn't that clear the current cookie string?



It does the same thing in IE. So I think there must be some rule there. Any ideas?


More From » html

 Answers
11

Cookies are set to expire, since we can't really delete them, we just force them to expire with a past date.



function deleteCookie(name) {
document.cookie = name + '=;expires=Thu, 05 Oct 1990 00:00:01 GMT;';
};

deleteCookie('newcookie')

[#77767] Wednesday, June 5, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
sashacitlallik

Total Points: 30
Total Questions: 100
Total Answers: 85

Location: Belarus
Member since Tue, Mar 14, 2023
1 Year ago
;