如何删除tab关闭时的angular.js v 1.3 cookies

时间:2015-12-10 13:19:38

标签: javascript angularjs cookies

我想删除tab close上的angular.js中的cookie。

$(window).on('beforeunload', function() {       
            delete $cookies["Email"];
            delete $cookies["isLoggedIn"];
            delete $cookies["Token"];
            delete $cookies["Name"];    
            delete $cookies["LogCode"];
        }); 

我在app.js中调用了这个函数,但它不起作用。你能否就这个问题向我提出建议? 请注意:我正在使用angular.js版本1.3

1 个答案:

答案 0 :(得分:0)

希望这有帮助

//处理页面刷新和标签关闭

$window.onbeforeunload = function(){

        $cookies.remove('Email');
        $cookies.remove('isLoggedIn');
        //Delete rest of the cookies similarly

};