JavaScript Deletes all cookie instance codes

Source: Internet
Author: User

JavaScript Deletes all cookie instance codes:
In general, it is the deletion of the specified cookie, of course, you can delete all cookies at once, the following is a piece of code to implement this function.
The code is as follows:

function ClearCookie () {   var keys=document.cookie.match (/[^ =;] + (? =\=)/g);    if (keys) {     for (var i=keys.length;i--;) {      document.cookie=keys[i]+ ') =0;expires= ' +new Date (0). toUTCString ()     }  

Run the above function to clear all cookies. The code is simple, it is to get all the cookie array, and then through the for loop to set the cookie expiration, there is not much to introduce.
Related reading:
1.js manipulation cookies can be found in the section on how JavaScript operates cookies .
2. Operation Cookie plugin javascript application Cookie Encapsulation code chapter.

The original address is: http://www.softwhy.com/forum.php?mod=viewthread&tid=9502

For more information, refer to: http://www.softwhy.com/javascript/

JavaScript Deletes all cookie instance codes

Related Article

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.