HOME

Saturday, August 18, 2012

Delete all directory cookies in javascript


           var name = "loginstatus";
            var pathBits = location.pathname.split('/');
            var pathCurrent = ' path=';

            // do a simple pathless delete first.
            document.cookie = name + '=; expires=Thu, 01-Jan-70 00:00:01 GMT; path=/; domain = www.citycinemas.in;';

            for (var i = 0; i < pathBits.length; i++) {
                pathCurrent += ((pathCurrent.substr(-1) != '/') ? '/' : '') + pathBits[i];
                document.cookie = name + '=; expires=Thu, 01-Jan-70 00:00:01 GMT;' + pathCurrent + ';';
            }

No comments:

Post a Comment