JavaScript Action Cookie Simple plugin:
The appropriate and flexible use of cookies can bring a lot of convenience to users, although it has been criticized by many people, but its application is everywhere, about the cookie is not introduced here, specifically, you can refer to JavaScript how to operate the cookie section, Here is a simple plugin for manipulating cookies, with the following code:
varCookie={ //Create a cookieSetcookie:function(name, value, Iday) {varOdate =NewDate (); Odate.setdate (Odate.getdate ()+iday); Document.cookie= name+ ' = ' +value+ '; expires= ' +odate; }, //Read CookiesGetCookie:function(name) {vararr = Document.cookie.split ('; ‘); for(vari = arr.length-1; I >= 0; i--) { varARR2 = arr[i].split (' = ')); if(arr2[0]===name) { returnArr2[1]; } } return‘‘; }, //Delete CookiesRemovecookie:function(name) {Cookie.setcookie (name,1,-1); } };
This plugin provides three features for creating cookies, reading cookies, and deleting cookies, and the code demonstrates:
Cookie.setcookie (' username ', ' Ant Tribe '),Cookie.removecookie (' username ');
The above code first creates a cookie with the name "username", the value "Ant Tribe", expires after 30 days, and the second paragraph is to delete this cookie.
The original address is: http://www.softwhy.com/forum.php?mod=viewthread&tid=7980
For more information, refer to: http://www.softwhy.com/javascript/
JavaScript Action Cookie Simple plugin