Adding, deleting, modifying and checking cookies by JavaScript
· Memo notes · 0 comment · 1,247 Views

Adding, deleting, modifying and checking cookies by JavaScript

· Memo notes · 0 comment · 1,247 Views

 Blow up your sister

When you blow up your sister, you are going to add an authentication cookie to jump to the advertising page, so there is this article.

JavaScript writes cookies

 function setCookie(c_ name, value, expiredays, path) {
        var exdate = new Date();
        exdate.setDate(exdate.getDate() + expiredays);
        document.cookie = c_ name + "=" + escape(value) + ((expiredays == null) ? "" : ";expires=" + exdate.toGMTString()) + ";" + ((path == null) ? "" : "path=" + escape(path));
    }
    setCookie("znm", "zhanimei.com", 24);

Cookie read JavaScript

 function getCookie(c_ name) {
        if (document.cookie.length > 0) {
            c_ start = document.cookie.indexOf(c_ name + "=");
            if (c_ start != -1) {
                c_ start = c_ start + c_ name.length + 1;
                c_ end = document.cookie.indexOf(";", c_ start);
                if (c_ end == -1) c_ end = document.cookie.length;
                return unescape(document.cookie.substring(c_ start, c_ end));
            }
        }
        return "";
    }

JavaScript delete cookie

 function delCookie(name) {
        var date = new Date();
        date.setTime(date.getTime() - 10000);
        document.cookie = name + "=a; expires=" + date.toGMTString() + ";path=*";
    }

Cookie clear all JavaScript

 function removeCookie() {
        var cookie = document.cookie.split(";");
        for (var i in cookie) {
            delCookie(cookie[i].substring(cookie[i].indexOf("="), 0));
        }
    }
Add a new comment