Astw41
Astw41

Reputation: 392

Jquery-cookie plugin - how to set "expires" to less than 1 day?

I'm trying to save info about the checkboxes (if they are checked or not) in a cookie (jquery-cookie plugin). The problem is that the plugin doesn't allow anything less than 1 day to set in the "expires" line.

$(document).ready(function(){
    $(".ing_check").each(function(){
        var name = $(this).attr('name');
        if($.cookie(name) && $.cookie(name) == "true"){
            $(this).prop('checked', $.cookie(name));
        }
    });
    $(".ing_check").change(function(){
        var date = new Date();
        date.setTime(date.getTime()+(3*1000));

        var name = $(this).attr('name');
        $.cookie(name, $(this).prop('checked')), {
            path: '/',
            expires: date // plugin allows values like 365 or 2 - for days
        }
    })
});

I'm trying to expire the cookie after 3 seconds, but failed to do so. Am I doing something wrong? Is there a way to do it correctly?

Upvotes: 0

Views: 63

Answers (0)

Related Questions