开发者

jQuery deleting cookies using cookies plugin

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.


Answered here:

https://code.google.com/p/cookies/wiki/Documentation

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜