Problem description:
You need to use a cross-origin cookie and cannot set or read the cookie.
The cookie uses jquery cookie. Download Address: http://plugins.jquery.com/cookie /.
To be honest, the official method of use is really incomprehensible. Fortunately, it is awesome for netizens.
Briefly describe the usage method:
Write cookie:
$. Cookie ('php', 'phpdo ');
Read cookie:
$. Cookie ('php'); // cookie existence => 'phpdo'
Delete cookie:
Pass null as the cookie value.
$. Cookie ('php', null );
My cookie: $. cookie ("name", name, {path: '/', domain: 'uelife. Cn', secure: true });
After searching for half a day, no problem was found. During the tangle, I accidentally saw the parameter again. Open.
Secure: true: if it is true, secure protocol (HTTPS) is required for cookie transmission ).
The web I use is http, but it cannot be opened.
Okay. Today, a hand owe error still occurred.
Parameters:
1). expires: 365
Defines the effective time of a cookie. The value can be a number (counted from the cookie creation time, in days) or a Date object. If this parameter is omitted, the created cookie is a session cookie and will be deleted when the user exits the browser.
2). path :'/'
Default: only webpages with cookie settings can read the cookie.
Defines the valid cookie path. By default, the value of this parameter is the path of the page where the cookie is created (the behavior of the standard browser ).
If you want to access this cookie on the entire website, you need to set the valid path as follows: path :'/'.
If you want to delete a cookie that defines a valid path, you need to include this path when calling the function: $. cookie ('php', phpdo, {path :'/'});.
Domain: 'phpdo. Net'
Default value: the domain name of the webpage for which the cookie is created.
3). secure: true
Default value: false. If the value is true, the secure protocol (HTTPS) is required for cookie transmission ).
4). raw: true
Default value: false.
By default, the system automatically performs encoding and decoding (encodeURIComponent encoding and decodeURIComponent decoding) when reading and writing cookies ). To disable this function, set raw: true.