JavaScript Intensive Tutorial-cookie Object

Source: Internet
Author: User

This article ish5eduAgency officialHTML5 Trainingtutorials, the main introduction:JavaScript Intensive Tutorials--cookie Object
 
Cookie object:

is a user data information (cookie data) stored in the cookie folder of the client's hard disk in the form of a file (cookies file). The cookie file is established by the Web site visited to hold the session data between the client and the Web site for a long time, and the cookie data is only allowed to be read by the Web site visited.
 
Storing Cookies

<script> function Savecookie (cname,cvalue,exdays) {var d = new Date ();        D.settime (D.gettime () +exdays*24*60*60*1000);        var exprices = "exprices=" + d.togmtstring (); Document.cookie = cname+ "=" +cvalue+ ";"    +exprices; }

read Cookies

 function  readcookie (CNAME) {        var name  = cname+ "=";         var ck =document.cookie.split (";");         for (var n=0;n<ck.length;n++) {             var c=ck[n].trim ();             if (C.indexof ("name") ==0) {                 return c.substr (name.length, c.length);             }        }     } 

html

<input type= "button" value= "Storage" <input type= "button" value= "read" onclick= "alert (Readcookie (' name '))" >

Click to enter JS Intensive tutorial

This article is from the "11721999" blog, please be sure to keep this source http://11731999.blog.51cto.com/11721999/1826679

JavaScript Intensive Tutorial-cookie Object

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.