javascript - Removing Cookie value from browser -


i know has been asked many times, , ive tried using accepted answers. sadly none of seems work me in browser(mozilla v18.0.2).

i using backbone website , im using cookies handle user login sessions.

the following unsuccessful ones :

code 1

var cookie_date = new date ( );  // cookie_date.settime ( cookie_date.gettime() - 1 ); // 1 second before now. // empty cookie's value , set expiry date time in past. document.cookie = "uid=;expires=" + cookie_date.togmtstring(); document.cookie = "username=;expires=" + cookie_date.togmtstring(); 

code 2

var nameeq = name + "=";     var ca = document.cookie.split(';');     for(var i=0;i < ca.length;i++) {         var c = ca[i];         while (c.charat(0)==' ') c = c.substring(1,c.length);         if (c.indexof(nameeq) == 0){             uid = c.substring(nameeq.length,c.length);             return uid;         }  }; 

any working solution removing browser cookies??

thanks

roy

simple answer

you can't.

long answer

you can overwrite cookie , give expiration time in past.

browsers discard @ point after expiration. until need check yourself, if has been “deleted”, e. g. special value or comparing expiration date current time.


Comments

Popular posts from this blog

How to mention the localhost in android -

php - Calling a template part from a post -

c# - String.format() DateTime With Arabic culture -