javascript - Issue while clearing the cookie from html page -


i have home.aspx , aboutus.html page.when click on logout of aboutus page,my cookie not cleared,when came home page. below piece of code m using save & delete cookie

    var savecookie = function(znamep, zvaluep, ispersistencep)     {         ispersistencep = typeof ispersistencep !== 'undefined' ? ispersistencep : false;         if (ispersistencep)             savepersistencecookie(znamep, zvaluep);         else             document.cookie = znamep + "=" + escape(zvaluep);     }     function savepersistencecookie(znamep, zvaluep)     {         var expirationdate = new date();         expirationdate.setdate(expirationdate.getyear() + 1); //1 year         var cookievaluel = escape(zvaluep) + "; expires=" + expirationdate.togmtstring();         document.cookie = znamep + "=" + cookievaluel;     }      function deletecookie(znamep)     {         document.cookie = znamep + '=; expires=thu, 01-jan-70 00:00:01 gmt;';      } 

i m getting cookie value in home page after clearing in aboutus.html.what doing wong?

deleting cookies can interesting business due path portion of cookie definition. if path set when expiring cookie doesn't match of original cookie set won't clear it. should add path=/; (see below) when deleting cookie , double check cookie path in browser firebug/chrome dev tools/web developer toolbar/whatever else.

here's js function have deleting cookies. notice how specify path=/;:

function delcookie(name) {   document.cookie = name + '=; path=/; expires=thu, 01-jan-70 00:00:01 gmt;'; } 

if, whatever reason, when cookie created has different value / path function not work. and, unfortunately, there no way access cookie information such domain or path javascript.


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

How to get multiresult with multicondition in Sql Server -