How to clear a large number of cookies generated by CNZZ site statistics code

Source: Internet
Author: User
Tags split chrome developer chrome developer tools

Today, when I was visiting the garden, I looked at the cookies in Chrome and didn't know it.

The cookies that start with CNZZ are covered with the Chrome Developer Tools window, see the screenshot below:

See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/web/Skills/

In June, a blog post--CNZZ statistical code caused bad Request-request Too Long. Six months later, it seems that CNZZ has not solved the problem.

You may ask, "Since CNZZ has this problem, why use it?" ”。 No, we didn't use CNZZ, we used Google Analytics. Some bloggers have used cnzz in their blogs.

Since CNZZ didn't solve the problem, he had to do it himself.

Workaround:

To clear all Cnzz cookies with JavaScript code, the sample code is as follows:

function Clearcnzzcookies () {
    if (document.cookie.indexOf (' Cnzz ') >-1) {
        var cookies = Document.cookie.split (';')
        for (var i = 0; i < cookies.length i++) {
            if (cookies[i].indexof (' Cnzz ') >-1) {
                var cookiename = cookies[i ].split (' = ') [0];
                Document.cookie = CookieName + "=deleted; expires= "+ new Date (0). toutcstring ();
                Console.log (cookiename + "removed");}}}

The idea is to find all the Cnzz cookies from Document.cookie, and then modify the cookie value and let it expire immediately.

Code Run Results:

Then, Chrome is quiet.

This code has been used in the garden, when visiting the home page of the blog, if there is a CNZZ cookie will be cleared.

Author: cnblogs Dudu

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.