Reprinted: http://www.chinawebanalytics.cn/%E6%8D%8D%E5%8D%ABcookie%E2%80%94%E2%80%94%E6%B2%A1%E6%9C%89cookie%EF%BC%8C%E6%88%91%E4%BB%AC%E4%BB%80%E4%B9%88%E9%83%BD%E6%B2%A1%E6%9C%89%E4%BA%86/
Before starting the text, let's talk a little bit about it. Google Analytics recently launched the API function. developers can integrate the data and functions of Google Analytics into their own applications. For more information, see here.
Theme. When Microsoft hasn't launched IE8, I honestly don't like
Create a username cookie on the client with a value of GJY, valid for 1 days.Method 1:response.cookies["username"]. Value= "ZXF";response.cookies["username"]. Expires=datetime.now.adddays (1);
Method 2:System.Web.HttpCookie newcookie=new HttpCookie ("username");Newcookie. Value= "Gjy";Newcookie. Expires=datetime.now.adddays (1);Response.appendcookie (Newcookie);
To create a cookie with a subkey:System.Web.HttpCookie newcookie=new HttpCookie ("user");Newcookie. values["username"]= "ZXF";Newcookie
name, then the corresponding JS code is:Document.cookie= "Name=" +username;JS Read Cookie:Assume that the content stored in the cookie is: name=jack;password=123The JS code that gets the value of the variable username in the B page is as follows:var username=document.cookie.split (";") [0].split ("=") [1];//js how to operate cookies!//write Cookiesfunction Setcookie (name,value){var days = 30;var exp = new Date ();Exp.settime (Exp.gettime () + days*2
Use JS to set cookies, read cookies, delete cookiesJavaScript is a script that runs on the client, so it is generally not possible to set the session because the session is running on the server side.The cookie is run on the client, so you can use JS to set the cookie.Suppose there is a case, in a use case process, a page jumps to page B, if the a page with the variable temp Save the value of a variable, in
Cross-origin Cookie Access
Easy Cross Domain cookies (sharing cookies between domains)
I own several websites that need memberships to post comments, and recently I wanted the ability to have a single login-so once the user is logged into one site they are automatically logged into the others.
Ideally, I cocould just write the login cookies for both doma
http://www.crifan.com/python_auto_handle_cookie_and_save_to_from_cookie_file/#!/usr/bin/python#-*-coding:utf-8-*-"" "Function:" Organize "the processing of cookies in Python: Automatically process cookies, save as cookie files, load cookies from files/HTTP/ Www.crifan.com/python_auto_handle_cookie_and_save_to_from_cookie_file version:2013-01-15author:crifancon
name, then the corresponding JS code is:Document.cookie= "Name=" +username;JS Read Cookie: Assume that the content stored in the cookie is: name=jack;password=123The JS code that gets the value of the variable username in the B page is as follows:var username=document.cookie.split (";") [0].split ("=") [1];//js how to operate cookies!//write Cookiesfunction Setcookie (name,value){var days = 30;var exp = new Date ();Exp.settime (Exp.gettime () + days*
JavaScript is a script that runs on the client, so it is generally not possible to set a session because the session is run on the server side.
Cookies are run on the client, so you can use JS to set cookies.
Suppose there is a case in which, in a use-case process, from a page to the B page, if the a page using JS variable temp saved a variable of the value, in the B page, the same need to use JS to refer
name, then the corresponding JS code is:Document.cookie= "Name=" +username;JS Read Cookie:Assume that the content stored in the cookie is: name=jack;password=123The JS code that gets the value of the variable username in the B page is as follows:var username=document.cookie.split (";") [0].split ("=") [1];//js how to operate cookies!//write Cookiesfunction Setcookie (name,value){var days = 30;var exp = new Date ();Exp.settime (Exp.gettime () + days*2
name, then the corresponding JS code is:Document.cookie= "Name=" +username;JS Read Cookie:Assume that the content stored in the cookie is: name=jack;password=123The JS code that gets the value of the variable username in the B page is as follows:var username=document.cookie.split (";") [0].split ("=") [1];//js how to operate cookies!//write Cookiesfunction Setcookie (name,value){var days = 30;var exp = new Date ();Exp.settime (Exp.gettime () + days*2
name, then the corresponding JS code is:Document.cookie= "Name=" +username;JS Read Cookie: Assume that the content stored in the cookie is: name=jack;password=123The JS code that gets the value of the variable username in the B page is as follows:var username=document.cookie.split (";") [0].split ("=") [1];//js how to operate cookies! //write Cookies function Setcookie (name,value){var days = 30;var exp =
JavaScript is a script that runs on the client, so it is generally not possible to set the session because the session is running on the server side.The cookie is run on the client, so you can use JS to set the cookie.Suppose there is a case, in a use case process, a page jumps to page B, if the a page with the variable temp Save the value of a variable, in the B page, also need to use JS to reference the variable value of temp, for JS in the global variable or static variable life cycle is limi
name, then the corresponding JS code is:Copy CodeThe code is as follows:Document.cookie= "Name=" +username;JS Read Cookie:Assume that the content stored in the cookie is: name=jack;password=123The JS code that gets the value of the variable username in the B page is as follows:?
12345678910
var username=document.cookie.split(";")[0].split("=")[1];//JS操作cookies方法!//写cookiesfunction setCookie(name,value){var Days = 30;var exp = new Dat
name, then the corresponding JS code is:Copy the code code as follows:Document.cookie= "Name=" +username;JS Read Cookie:Assume that the content stored in the cookie is: name=jack;password=123The JS code that gets the value of the variable username in the B page is as follows:
12345678910
varusername=document.cookie.split(";")[0].split("=")[1];//JS操作cookies方法!//写cookiesfunctionsetCookie(name,value){varDays = 30;var exp = newDate();exp
name, then the corresponding JS code is:Document.cookie= "Name=" +username; JS Read Cookie:Assume that the content stored in the cookie is: name=jack;password=123The JS code that gets the value of the variable username in the B page is as follows:var username=document.cookie.split (";") [0].split ("=") [1]; //js how to operate cookies!//Write CookiesfunctionSetcookie (name,value) {varDays = 30; varExp =NewDate (); Exp.settime (Exp.gettime ()+ days*
name, then the corresponding JS code is:Document.cookie= "Name=" +username;JS Read Cookie:Assume that the content stored in the cookie is: name=jack;password=123The JS code that gets the value of the variable username in the B page is as follows:var username=document.cookie.split (";") [0].split ("=") [1];//js how to operate cookies!//write Cookiesfunction Setcookie (name,value){var days = 30;var exp = new Date ();Exp.settime (Exp.gettime () + days*2
variable username ("Jack") in the a page to the cookie, the key value is name, then the corresponding JS code is:Document.cookie= "Name=" +username;JS Read Cookie:Assume that the content stored in the cookie is: name=jack;password=123The JS code that gets the value of the variable username in the B page is as follows:var username=document.cookie.split (";") [0].split ("=") [1];//js how to operate cookies!//write Cookiesfunction Setcookie (name,value)
Today, the PHP cookie must be refreshed and the problem can be resolved as follows:PHP cookie setting function takes effect immediately, supports arrayfunction Cookie ($var, $value = ', $time = 0, $path = ', $domain = ', $s = false){$_cookie[$var] = $value;if (Is_array ($value)) {foreach ($value as $k = = $v) {Setcookie ($var. ' ['. $k. '] ', $v, $time, $path, $domain, $s);}} else {Setcookie ($var, $value, $time, $path, $domain, $s);}}This will not be refreshed, directly can get the value of the
first, from the writing cookie.。
var the_date = new Date ("December 31, 2020");
var expiresdate = the_date.togmtstring ();
Document.cookie = "userdefinecss=" + Escape (title) + "; expires= "+ expiresdate;
The first sentence is the date object;
The second sentence converts the date format to GMT format; The editor: GMT, Greenwich Mean Time, is now also called UTC, the global standard Time.
The third sentence is to write the cookie content to the client.
Where the expires is used by the system, in
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.