Wednesday, 15 January 2014

javascript - How do I delete this cookie -



javascript - How do I delete this cookie -

so have had utilize cookie remember selection - awesome works, need remove in under on click event, awesome... not working me, here using implement onclick event (which seems work tried alert beingness triggered.)

$(document).ready(function () { $('#dnn_ctr555_productsearch_rpdata_cmdadvsearch_0').click(function () { $.cookie('myddidx', null,{ path: '/' }); }); });

here script using create cookie

var sidx = document.cookie.indexof("myddidx"); if(sidx != -1) window.onload = function () { document.getelementbyid("selection").selectedindex = document.cookie.substr(sidx + 8,1); } <select id="selection" class="sorter" onchange="document.cookie= 'myddidx = ' + this.selectedindex + '; path=/;';location=this.options[[this.selectedindex]].value" style="float:right;margin-right:8px;">

this sending me wall path, have nothing.

i'm assuming you're using jquery library: https://github.com/carhartl/jquery-cookie

from readme documentation:

... when deleting cookie, must pass exact same path, domain , secure options used set cookie ...

since you're setting cookie using path=/:

document.cookie= 'myddidx = ' + this.selectedindex + '; path=/;'

to remove cookie, need use:

$.removecookie("myddidx", { path: '/' });

javascript jquery cookies

No comments:

Post a Comment