Cookies cannot be written in Chinese because of the innate encoding of cookies. So there needs to be an intermediate encoding for the transition. UrlEncode is the best choice.
We take asp.net for example, the code is as follows:
when setting
Method One
If you do not use cookies, sending an HTTP POST is very simple:
The code is as follows
Copy Code
Import Urllib2, Urllibdata = {' name ': ' www ', ' password ': ' 123456 '}f = Urllib2.urlopen (url = '
Set cookieEach cookie is a name/value pair. You can assign the following string to document. COOKIE:Document. Cookie = "userid = 828 ";To store multiple name/value pairs at a time, use semicolons (;) to separate them. For example:Document. Cookie = "
Set Cookies
Each cookie is a name/value pair, and you can assign a string such as the following to Document.cookie:
Document.cookie= "userid=828";
If you want to store more than one name/value pair at a time, you can use a semicolon plus a space (
Document. cookie = "userId = 828 ";To store multiple name/value pairs at a time, use semicolons (;) to separate them. For example:Document. cookie = "userId = 828; userName = hulk ";The names or values of cookies cannot contain semicolons (;),
PHP setcookie () usage and phpsetcookie usageDefinition and usage
The setcookie () function sends an HTTP cookie to the client.
Cookie is a variable sent from the server to the browser. Cookies are usually small text files embedded into users'
PHPsetcookie () and phpsetcookie. PHPsetcookie () usage. phpsetcookie uses the statutory and usage setcookie () functions to send an HTTPcookie to the client. Cookie is a variable sent from the server to the browser. PHP setcookie () and
Function getCookie (name ){Var Found = falseVar start, endVar I = 0
// Cookie.While (I Start = IEnd = start + name. length// Name brace old eggplant Lei Ah happy to restIf (document. cookie. substring (start, end) = name ){Found = trueBreak}I ++}
/
The cookie cannot contain Chinese characters because of its inherent encoding method. Therefore, an intermediate encoding is required for transition. URLEncode is the best choice.Take asp.net as an example. The Code is as follows:When setting
session the biggest difference between cookie is that session is stored in Server Memory , while cooki E Save in a browser or client file ; session is based on access process , which records the start and end of an access. When the
Error message:A potentially dangerous request. form value was detected from the client(Txttest = " ").In. net, when a request contains a string such as HTML or Javascript, the system considers the request to be dangerous.Risk value. An error is
Session: in the memory of the server;
COOKIE: in the browser of the client;
Generally, when session is used, there will be an entity class used to store user name and other data, so here we define a class;
There are two fields: user name and
Cookie Cookies [] = request. getcookies (); // read the cookies on the user's hard disk and put all the cookies into a cookie object array. Cookie scookie = NULL; For (INT I = 0; I
Incorrect value occurred while using jquery to manipulate cookies:
The result is that cookies have four different properties:Name, content, domain, path
The code is as follows
Copy Code
$.cookie (' The_cookie '); Read
The code is as follows
Copy Code
*/function GetCookie (name) {var arg = name + "=";var alen = Arg.length;var clen = document.cookie.length;var i = 0;while (I var j = i + Alen;if (Document.cookie.substring (i, j) = arg)Return
Because the ASP's cookies are URL-coded, you should unescape them before you read them.
Here's how I use the regular method to fetch cookies, including single and multivalued:
When using JQuery to operate on cookies, the obtained values are incorrect. The results show that cookies have four different attributes, we will share with you the cause of the error and the solution to the problem of incorrect values when using
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.