I am using this plugin to store some cookies:
https://code.google.com/p/cookies/wiki/Documentation
I was wondering how i would go about deleting all cookies with a certain prefix and/or delete all cookies that have a certain value. I need this to be done once some user has completed their journey through my application.
For example i store the visible state of certain tables on a page like so:
// check visible status of table and persist
$('div.dependant').each(function(){
var $childCount = $(this).index('div.dependant');
$(this).addClass('tableStatus' + $childCount);
// get the value of the cookie
var $tableStatus = $.cookies.get('tableStatus' + $childCount);
// if variable not null
if ($tableStatus) {
if ($tableStatus == 'hidden') {
$('.tableStatus' + $childCount).hide();
} else if ($tableStatus == 'visible') {
$('.tableStatus' + $childCount).show();
}
}
});
So the cookies will be 'tableStatus0', 'tableStatus1' etc...
I could manually delete but there will be an unknown number of tables.