JavaScript cookie: Cross-origin access advertisement promotion; javascriptcookie
In practical applications, the cross-region weather forecast component can be implemented using the above method. Another common method is to display some e-commerce advertisements, this advertisement will scroll through the products you have visited or products promoted to you by Lenovo.
For example, A webpage A displays two t
', '. example.com ' (including all subdomains), ' subdomain.example.com ') if there is no definition, the domain name portion of the path that defaults to the current document location.
(3) Max-age=max-age-in-seconds (for example, one year for 606024*365)
(4) Expires=date-in-gmtstring-format if not defined, the cookie expires at the end of the conversation. The format of this value is see date.toutcstring ().
(5) Secure (cookies are transmitted on
JavaScript and dynamic pages cannot get the time the cookie expires, the browser manages the expiration time, and JavaScript and dynamic pages can only set expiration time. cannot be obtained through Document.cookie (JavaScript) or Cookie.expires (asp.net) properties.
The code is as follows:
protected void Page_L
21 days to learn javascript: Cookie Encoding
This article is excerpted from "21 days learning JavaScript"
Cookies are stored in the cookie file in an unencoded format. However, cookies do not contain special characters such as spaces, semicolons, and commas. If you want to write these special symbols into the
JavaScript checks whether the browser cookie has been started. javascriptcookie
This example describes how to use JavaScript to check whether a browser cookie has been started. Share it with you for your reference. The specific analysis is as follows:
JavaScript checks whe
How to obtain the cookie expiration time using javascript
Javascript and dynamic pages cannot get the cookie expiration time. The expiration time is managed by the browser. javascript and dynamic pages can only set the expiration time, but cannot pass the document.
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--;) {
Javascript read/write cookie operation by shawl. Qiu
Note:Javascript cookies are really weak enough for you to write cookie values, such:
Linenum
Value = This: value1 = This
But you cannot directly read the value or value1.You can only set the validity period using time. togmtstring (). All other time formats are invalid.
The value content c
You need to be aware of attributes such as Httponly,path. The Complete test code:ASPX Code"Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >Meng XianhuaHow JavaScript removes the multi-valued Cookie set by ASP.
This article mainly introduces JS encapsulated cookie operation functions, and analyzes the related techniques for setting, obtaining, and deleting cookies in JavaScript in the form of examples. It has some reference value, for more information, see the examples in this article. We will share this with you for your reference. The details are as follows:
/* Set cook
This example describes the JavaScript manipulation cookie class. Share to everyone for your reference. Specifically as follows:
Usage:
One, set cookies
var cookie = new Jscookie ();
Normal settings
cookie. Setcookie ("Key1", "Val1");
The expiration time is one year
var expire_time = new Date ();
Expire_time.s
This article mainly introduces how to implement the memo record for js cookie operations, and involves the JavaScript-targeted cookie read/write operations related skills, for more information, see the examples in this article. We will share this with you for your reference. The details are as follows:
The Code is as follows:
Function getCookie (c_name) {if
1 //1. Get the value of a cookie with the specified name objname2 functionGetCookie (objname) {3 varArrstr = Document.cookie.split (";");//between the various cookies;4 for(vari=0;i){5 vartemp = arrstr[i].split ("=");//the cookie name and cookie value are separated by =6 if(Temp[0] = =objname)7 returnUnescape (temp[1]);8 }
Keep in mind that cookies are a string property of a document. To save a cookie, simply create a string, the format is name=
The code is as follows
Copy Code
Document.cookie = "username" + Escape (form.username.value);
It is important to use the escape () function here because the cookie value may contain semicolons, commas,
Generally, few users want to disable javascript. Therefore, JavaScript, Ajax, cookie, and other technologies are more or less used to achieve good user experience and webpage effects.
However, the existing Web attacks often use these mobile code (JavaScript, Cookie, Flash,
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.