Cookie settings, acquisition, and deletion

Source: Internet
Author: User

Let's start by introducing basic information about cookies:

The cookie is in the domain, it must be placed in the environment of the server, but the capacity of the cookie is small, only 4kb, and also is not safe, and the name of the shares of the cookie is the same, will modify or overwrite the original value, if the name is different, will add a cookie;

And then I'll talk to you about getting cookies:

The format in which the cookie is obtained is a string;

A cookie in the parent seed, which can be obtained by a child, or a cookie under a child, which is not obtained by the parent;

There is the path of the cookie: can be set, is generally set to the '/' root directory;

Okay, here's what I've encapsulated. Three usage functions of cookies;

Document.cookie='ac=123'; //species undera cookie;function Setcookie (name,value,iday) {if(iday) {varOdate=NewDate (); Odate.setdate (Odate.getdate ()+iday); Document.cookie=name+'='+value+';p ath=/;expires='+odate; }Else{Document.cookie=name+'='+value+';p ath=/'; }} Setcookie ('ASD','123'); Setcookie ('qwe','TD',3); //get a cookie;function GetCookie (name) {varArr=document.cookie.split ('; ');  for(varI=0; i<arr.length;i++){                varTmp=arr[i].split ('='); if(name==tmp[0]){                    returntmp[1]; }            }            return "'; }        //delete a cookie;function Removecookie (name) {Setcookie (name,'ASD',-1)} removecookie ('ASD')

What is wrong to write the place, I hope you leave a message guidance, thank you O (∩_∩) o Thank you!!!

Cookie settings, acquisition, and deletion

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.