\n \u8ba9\u6211\u4eec\u770b\u4e00\u4e2acookie expires\u5c5e\u6027\u7684\u4f8b\u5b50\u3002\n<\/div>\n
\n
<!DOCTYPE html>
<html>
<head>
<\/head>
<body>
<input type=\"button\" value=\"setCookie\" onclick=\"setCookie()\">
<input type=\"button\" value=\"getCookie\" onclick=\"getCookie()\">
<script>
function setCookie()
{
document.cookie=\"username=Duke Martin;expires=Sun, 20 Aug 2030 12:00:00 UTC\";
}
function getCookie()
{
if(document.cookie.length!=0)
{
var array=document.cookie.split<\/span>(\"=\");
alert(\"Name=\"+array[0]+\" \"+\"Value=\"+array[1]);
}
else
{
alert(\"Cookie not available\");
}
}
<\/script>
<\/body>
<\/html>
<\/span><\/code><\/pre>\n<\/div>\n Cookie max-age\u5c5e\u6027<\/h2>\n\n cookie max-age\u5c5e\u6027\u63d0\u4f9b\u4e86\u53e6\u4e00\u79cd\u521b\u5efa\u6301\u4e45\u6027cookie\u7684\u65b9\u6cd5\u3002\u5728\u8fd9\u91cc\uff0c\u65f6\u95f4\u4ee5\u79d2\u4e3a\u5355\u4f4d\u3002 Cookie\u4ec5\u5728\u58f0\u660e\u7684\u65f6\u95f4\u5185\u6709\u6548\u3002\n<\/div>\n
\n \u8ba9\u6211\u4eec\u770b\u4e00\u4e2acookie max-age\u5c5e\u6027\u7684\u793a\u4f8b\u3002\n<\/div>\n
\n
<!DOCTYPE html>
<html>
<head>
<\/head>
<body>
<input type=\"button\" value=\"setCookie\" onclick=\"setCookie()\">
<input type=\"button\" value=\"getCookie\" onclick=\"getCookie()\">
<script>
function setCookie()
{
document.cookie=\"username=Duke Martin;max-age=\" + <\/span>(60 * 60 * 24 * 365) + \";\"
}
function getCookie()
{
if(document.cookie.length!=0)
{
var array=document.cookie.split<\/span>(\"=\");
alert(\"Name=\"+array[0]+\" \"+\"Value=\"+array[1]);
}
else
{
alert(\"Cookie not available\");
}
}
<\/script>
<\/body>
<\/html>
<\/span><\/code><\/pre>\n<\/div>\n Cookie path\u5c5e\u6027<\/h2>\n\n \u5982\u679c\u4e3a\u7f51\u9875\u521b\u5efa\u4e86cookie\uff0c\u5219\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u5b83\u4ec5\u5bf9\u5f53\u524d\u76ee\u5f55\u548c\u5b50\u76ee\u5f55\u6709\u6548\u3002 JavaScript\u63d0\u4f9b\u4e86\u4e00\u4e2apath\u5c5e\u6027\uff0c\u53ef\u5c06cookie\u7684\u8303\u56f4\u6269\u5c55\u5230\u7f51\u7ad9\u7684\u6240\u6709\u9875\u9762\u3002\n<\/div>\n
Cookie\u8def\u5f84\u5c5e\u6027\u793a\u4f8b<\/h2>\n\n \u8ba9\u6211\u4eec\u4e86\u89e3\u4f7f\u7528\n<\/div>\n
<\/p>\n
\n \u5728\u8fd9\u91cc\uff0c\u5982\u679c\u6211\u4eec\u4e3awebpage2\u521b\u5efa\u4e00\u4e2acookie\u3002 html\uff0c\u4ec5\u5bf9\u5176\u81ea\u8eab\u53ca\u5176\u5b50\u76ee\u5f55(\u5373webpage3.html)\u6709\u6548\u3002\u5bf9\u4e8ewebpage1.html\u6587\u4ef6\u65e0\u6548\u3002\n<\/div>\n
\n \u5728\u6b64\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528path\u5c5e\u6027\u6765\u589e\u5f3acookie\u5bf9\u6240\u6709\u9875\u9762\u7684\u53ef\u89c1\u6027\u3002\u5728\u8fd9\u91cc\uff0c\u60a8\u53ea\u9700\u8981\u7ef4\u62a4\u4e0a\u9762\u7684\u76ee\u5f55\u7ed3\u6784\uff0c\u5e76\u5c06\u4e0b\u9762\u7684\u7a0b\u5e8f\u653e\u5728\u6240\u6709\u4e09\u4e2a\u7f51\u9875\u4e2d\u5373\u53ef\u3002\u73b0\u5728\uff0c\u8be5cookie\u5bf9\u6bcf\u4e2a\u7f51\u9875\u5747\u6709\u6548\u3002\n<\/div>\n
\n
<!DOCTYPE html>
<html>
<head>
<\/head>
<body>
<input type=\"button\" value=\"setCookie\" onclick=\"setCookie()\">
<input type=\"button\" value=\"getCookie\" onclick=\"getCookie()\">
<script>
function setCookie()
{
document.cookie=\"username=Duke Martin;max-age=\" + <\/span>(60 * 60 * 24 * 365) + \";path=\/;\"
}
function getCookie()
{
if(document.cookie.length!=0)
{
var array=document.cookie.split<\/span>(\"=\");
alert(\"Name=\"+array[0]+\" \"+\"Value=\"+array[1]);
}
else
{
alert(\"Cookie not available\");
}
}
<\/script>
<\/body>
<\/html>
<\/span><\/code><\/pre>\n<\/div>\n Cookie domain\u5c5e\u6027<\/h2>\n\n JavaScript\u57df\u5c5e\u6027\u6307\u5b9acookie\u5bf9\u5176\u6709\u6548\u7684\u57df\u3002\u5047\u8bbe\u6211\u4eec\u662f\u5426\u5411\u5c5e\u6027\u63d0\u4f9b\u4efb\u4f55\u57df\u540d\uff0c\u4f8b\u5982\uff1a\n<\/div>\n
\n
domain=bianchenghao6.com
<\/span><\/code><\/pre>\n<\/div>\n\n \u5728\u6b64\uff0c\u8be5cookie\u5bf9\u7ed9\u5b9a\u57df\u53ca\u5176\u6240\u6709\u5b50\u57df\u5747\u6709\u6548\u3002\n<\/div>\n
\n \u4f46\u662f\uff0c\u5982\u679c\u6211\u4eec\u4e3a\u5c5e\u6027\u63d0\u4f9b\u4efb\u4f55\u5b50\u57df\uff0c\u4f8b\u5982\uff1a\n<\/div>\n
\n
omain=training.bianchenghao6.com
<\/span><\/code><\/pre>\n<\/div>\n\n \u5728\u6b64\uff0c\u8be5cookie\u4ec5\u5bf9\u7ed9\u5b9a\u7684\u5b50\u57df\u6709\u6548\u3002\u56e0\u6b64\uff0c\u8fd9\u662f\u63d0\u4f9b\u57df\u540d\u800c\u4e0d\u662f\u5b50\u57df\u7684\u66f4\u597d\u65b9\u6cd5\u3002\n<\/div>\n","protected":false},"excerpt":{"rendered":"JavaScript Cookie\u5c5e\u6027zh-cn","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[179],"tags":[],"class_list":["post-2694","post","type-post","status-publish","format-standard","hentry","category-javascript-jc"],"_links":{"self":[{"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/posts\/2694"}],"collection":[{"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/comments?post=2694"}],"version-history":[{"count":0,"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/posts\/2694\/revisions"}],"wp:attachment":[{"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/media?parent=2694"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/categories?post=2694"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/tags?post=2694"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}