WEB variable cookie

zhaozj2021-02-08  234

WEB variable cookie

[Author: Yangzhou BCB]

First, cookie overview:

Require related knowledge: web server, ISAPI programming, or JavaSCRPT script. Cookie (meaning of a small cookie) is some variables that are saved in the client when visiting the website, because the name of this word is not convinced, causing the cookie very simple, can be called For web variables, it is a mechanism for saving customer variables. When accessing the web page next time, the program in the web page can access these variables saved last time, of course, customers can close the browser cookie this feature, web pages The program cannot access or save these variables, so use the cookie purely aura small technology, without it can be sampled; but use cookie, web design can make customers convenient customers, so that some of the last inputs will be found again, free from Enter the contents of repetition;

Second, the JavaScript script Access to the cookie variable: JavaScript is a scriptor running on the client, with it to save the content of the text input box in the form of a cookie variable, and save the cookie at the client to reduce a little burden on the web server. :

1> Read the cookie: JavaScript can be accessed through Document.cookie to access all cookies: "Variable 1 = value 1; variable 2 = value 2; variable 3 = value 3;" You can get every variable name and Value; 2> Write cookie: email = "bush@usa.com"; firstname = "jorge"; LastName = "bush"; expiredate = "Thursday, 01-JAN-2099 12:00:00 GMT"; Document.cookie = "email =" email "; expires =" expireDate; document.cookie = "firstname =" firstname "; expires =" expireDate; document.cookie = "lastname =" lastname "; expires =" expireDate An example of the next page, automatically saved the text input box domain variable Name of the webpage: