{"id":97795,"date":"2024-10-29T15:14:40","date_gmt":"2024-10-29T07:14:40","guid":{"rendered":"https:\/\/www.073980.com\/?p=97795"},"modified":"2024-10-29T15:14:41","modified_gmt":"2024-10-29T07:14:41","slug":"cookie%e6%98%af%e4%bb%80%e4%b9%88%e6%84%8f%e6%80%9d%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/www.073980.com\/97795.htm","title":{"rendered":"Cookie\u662f\u4ec0\u4e48\u610f\u601d\uff1f"},"content":{"rendered":"\n

\u5728\u6570\u5b57\u5316\u65f6\u4ee3\uff0c\u4e92\u8054\u7f51\u5df2\u6210\u4e3a\u6211\u4eec\u65e5\u5e38\u751f\u6d3b\u4e0d\u53ef\u6216\u7f3a\u7684\u4e00\u90e8\u5206\u3002\u5f53\u6211\u4eec\u6d4f\u89c8\u7f51\u9875\u3001\u5728\u7ebf\u8d2d\u7269\u6216\u767b\u5f55\u793e\u4ea4\u5a92\u4f53\u65f6\uff0c\u6709\u4e00\u4e2a\u5c0f\u5c0f\u7684\u6587\u672c\u6587\u4ef6\u2014\u2014Cookie\uff0c\u5728\u9ed8\u9ed8\u53d1\u6325\u7740\u91cd\u8981\u4f5c\u7528\u3002<\/p>\n\n\n\n

\"\"<\/figure>\n\n\n\n

\u7b80\u4ecb<\/h2>\n\n\n\n

Cookie\u5728\u8ba1\u7b97\u673a\u9886\u57df\u4e2d\u5374\u626e\u6f14\u7740\u91cd\u8981\u7684\u89d2\u8272\u3002\u5b83\u662f\u4e00\u79cd\u7531\u670d\u52a1\u5668\u53d1\u9001\u5230\u7528\u6237\u6d4f\u89c8\u5668\u5e76\u4fdd\u5b58\u5728\u7528\u6237\u8ba1\u7b97\u673a\u4e0a\u7684\u5c0f\u578b\u6587\u672c\u6587\u4ef6\u3002\u8fd9\u4e9b\u6587\u4ef6\u88ab\u670d\u52a1\u5668\u7528\u6765\u8bc6\u522b\u7528\u6237\u8eab\u4efd\u3001\u8ddf\u8e2a\u7528\u6237\u6d3b\u52a8\u3001\u4fdd\u5b58\u7528\u6237\u8bbe\u7f6e\u7b49\u3002\u7b80\u800c\u8a00\u4e4b\uff0cCookie\u5c31\u50cf\u662f\u4f60\u5728\u7f51\u7edc\u4e16\u754c\u4e2d\u7684\u201c\u8eab\u4efd\u8bc1\u201d\uff0c\u8bb0\u5f55\u7740\u4f60\u7684\u8eab\u4efd\u4fe1\u606f\u548c\u504f\u597d\u8bbe\u7f6e\u3002<\/p>\n\n\n\n

Cookie\u7684\u5b58\u50a8\u4f4d\u7f6e\u548c\u4f7f\u7528\u65b9\u5f0f\u56e0\u64cd\u4f5c\u7cfb\u7edf\u548c\u6d4f\u89c8\u5668\u7684\u4e0d\u540c\u800c\u6709\u6240\u5dee\u5f02\u3002\u5728Windows\u7cfb\u7edf\u4e2d\uff0cCookie\u6587\u4ef6\u901a\u5e38\u5b58\u653e\u5728\u7279\u5b9a\u7684\u6587\u4ef6\u5939\u4e2d\uff0c\u5982Windows 9X\u7cfb\u7edf\u4e2d\u7684C:\/Windows\/Cookies\uff0c\u6216Windows Vista\/7\u7cfb\u7edf\u4e2d\u7684C:\\Users\\user\\AppData\\Roaming\\Microsoft\\Windows\\Cookies\\Low\u3002\u8fd9\u4e9b\u6587\u4ef6\u4ee5\u201c\u7528\u6237\u540d@\u7f51\u7ad9\u5730\u5740[\u6570\u5b57].txt\u201d\u7684\u683c\u5f0f\u547d\u540d\uff0c\u8bb0\u5f55\u4e86\u4f60\u5728\u8be5\u7f51\u7ad9\u4e0a\u7684\u6d3b\u52a8\u4fe1\u606f\u3002<\/p>\n\n\n\n

\u7ec4\u6210<\/h2>\n\n\n\n

Cookie\u7531\u591a\u4e2a\u5b57\u6bb5\u7ec4\u6210\uff0c\u6bcf\u4e2a\u5b57\u6bb5\u90fd\u627f\u8f7d\u7740\u7279\u5b9a\u7684\u4fe1\u606f\u3002\u8fd9\u4e9b\u5b57\u6bb5\u5305\u62ec\uff1a<\/p>\n\n\n\n

\u540d\u79f0(Name)<\/strong>\uff1a\u7528\u4e8e\u6807\u8bc6Cookie\u7684\u552f\u4e00\u5b57\u7b26\u4e32\uff0c\u662fCookie\u7684\u8eab\u4efd\u8bc1\u660e\u3002<\/p>\n\n\n\n

\u503c(Value)<\/strong>\uff1a\u4e0e\u540d\u79f0\u76f8\u5173\u8054\u7684\u6570\u636e\uff0c\u8bb0\u5f55\u4e86\u7528\u6237\u7684\u5177\u4f53\u4fe1\u606f\u6216\u504f\u597d\u8bbe\u7f6e\u3002<\/p>\n\n\n\n

\u57df(Domain)<\/strong>\uff1a\u53ef\u4ee5\u8bbf\u95ee\u8be5Cookie\u7684\u57df\u540d\uff0c\u9650\u5236\u4e86Cookie\u7684\u4f7f\u7528\u8303\u56f4\u3002<\/p>\n\n\n\n

\u8def\u5f84(Path)<\/strong>\uff1a\u53ef\u4ee5\u8bbf\u95ee\u8be5Cookie\u7684URL\u8def\u5f84\uff0c\u8fdb\u4e00\u6b65\u7ec6\u5316\u4e86Cookie\u7684\u8bbf\u95ee\u6743\u9650\u3002<\/p>\n\n\n\n

\u8fc7\u671f\u65f6\u95f4(Expires)<\/strong>\uff1aCookie\u7684\u6709\u6548\u671f\uff0c\u51b3\u5b9a\u4e86Cookie\u5728\u4f55\u65f6\u5931\u6548\u3002<\/p>\n\n\n\n

\u5b89\u5168\u6807\u5fd7(Secure)<\/strong>\uff1a\u6307\u793a\u6d4f\u89c8\u5668\u53ea\u5728\u901a\u8fc7\u52a0\u5bc6\u534f\u8bae(\u5982HTTPS)\u53d1\u9001\u8bf7\u6c42\u65f6\u624d\u53d1\u9001\u8be5Cookie\uff0c\u589e\u5f3a\u4e86\u5b89\u5168\u6027\u3002<\/p>\n\n\n\n

HttpOnly\u6807\u5fd7<\/strong>\uff1a\u9632\u6b62\u5ba2\u6237\u7aef\u811a\u672c\u901a\u8fc7JavaScript\u8bbf\u95eeCookie\uff0c\u51cf\u5c11\u4e86\u8de8\u7ad9\u811a\u672c\u653b\u51fb(XSS)\u7684\u98ce\u9669\u3002<\/p>\n\n\n\n

\u5b89\u5168\u5a01\u80c1<\/h2>\n\n\n\n

\u5c3d\u7ba1Cookie\u5728Web\u5f00\u53d1\u4e2d\u626e\u6f14\u7740\u91cd\u8981\u7684\u89d2\u8272\uff0c\u4f46\u5b83\u4eec\u4e5f\u5e26\u6765\u4e86\u4e00\u4e9b\u6f5c\u5728\u7684\u5b89\u5168\u98ce\u9669\u3002\u8fd9\u4e9b\u98ce\u9669\u4e3b\u8981\u5305\u62ec\uff1a<\/p>\n\n\n\n

\u9690\u79c1\u6cc4\u9732<\/strong>\uff1aCookie\u53ef\u80fd\u5305\u542b\u7528\u6237\u7684\u4e2a\u4eba\u4fe1\u606f\uff0c\u5982\u7528\u6237\u540d\u3001\u7535\u5b50\u90ae\u4ef6\u5730\u5740\u7b49\u3002\u5982\u679c\u8fd9\u4e9bCookie\u88ab\u672a\u7ecf\u6388\u6743\u7684\u4eba\u83b7\u53d6\uff0c\u5c31\u53ef\u80fd\u5bfc\u81f4\u7528\u6237\u9690\u79c1\u6cc4\u9732\u7684\u98ce\u9669\u3002<\/p>\n\n\n\n

\u8de8\u7ad9\u811a\u672c\u653b\u51fb(XSS)<\/strong>\uff1a\u653b\u51fb\u8005\u901a\u8fc7\u6ce8\u5165\u6076\u610f\u811a\u672c\u6765\u83b7\u53d6\u7528\u6237\u7684Cookie\u4fe1\u606f\uff0c\u8fdb\u800c\u5192\u5145\u7528\u6237\u6216\u8fdb\u884c\u5176\u4ed6\u6076\u610f\u64cd\u4f5c\u3002<\/p>\n\n\n\n

\u4f1a\u8bdd\u52ab\u6301<\/strong>\uff1a\u653b\u51fb\u8005\u901a\u8fc7\u83b7\u53d6\u7528\u6237\u7684\u4f1a\u8bddID\u6216Cookie\u6765\u5192\u5145\u7528\u6237\u8eab\u4efd\uff0c\u8fdb\u884c\u975e\u6cd5\u64cd\u4f5c\u3002<\/p>\n\n\n\n

\u4f1a\u8bdd\u5b9a\u7f6e<\/h2>\n\n\n\n

\u4f1a\u8bdd\u5b9a\u7f6e(Session Fixation)\u662f\u4e00\u79cd\u653b\u51fb\u65b9\u5f0f\uff0c\u653b\u51fb\u8005\u901a\u8fc7\u83b7\u53d6\u6216\u9884\u6d4b\u6709\u6548\u7684\u4f1a\u8bddID\uff0c\u5728\u7528\u6237\u767b\u5f55\u4e4b\u524d\u6216\u5728\u7528\u6237\u4e0d\u77e5\u60c5\u7684\u60c5\u51b5\u4e0b\uff0c\u5c06\u5176\u4f1a\u8bddID\u66ff\u6362\u4e3a\u653b\u51fb\u8005\u5df2\u77e5\u7684\u4f1a\u8bddID\u3002\u8fd9\u6837\uff0c\u653b\u51fb\u8005\u5c31\u53ef\u4ee5\u5728\u7528\u6237\u767b\u5f55\u540e\uff0c\u5192\u5145\u7528\u6237\u8fdb\u884c\u975e\u6cd5\u64cd\u4f5c\u3002Cookie\u4f5c\u4e3a\u4f1a\u8bdd\u7ba1\u7406\u7684\u91cd\u8981\u5de5\u5177\uff0c\u5728\u4f1a\u8bdd\u5b9a\u7f6e\u653b\u51fb\u4e2d\u626e\u6f14\u7740\u5173\u952e\u89d2\u8272\u3002<\/p>\n\n\n\n

CSRF\u653b\u51fb<\/h2>\n\n\n\n

CSRF(Cross-Site Request Forgery\uff0c\u8de8\u7ad9\u8bf7\u6c42\u4f2a\u9020)\u662f\u4e00\u79cd\u7f51\u7edc\u5b89\u5168\u6f0f\u6d1e\uff0c\u653b\u51fb\u8005\u901a\u8fc7\u4f2a\u9020\u7528\u6237\u7684\u8bf7\u6c42\uff0c\u5229\u7528\u7528\u6237\u5728\u5df2\u767b\u5f55\u7684\u60c5\u51b5\u4e0b\u7684\u8eab\u4efd\u9a8c\u8bc1\u4fe1\u606f\uff0c\u5411\u670d\u52a1\u5668\u53d1\u9001\u6076\u610f\u8bf7\u6c42\uff0c\u4ece\u800c\u6267\u884c\u672a\u7ecf\u7528\u6237\u6388\u6743\u7684\u64cd\u4f5c\u3002\u5728CSRF\u653b\u51fb\u4e2d\uff0c\u653b\u51fb\u8005\u901a\u5e38\u4f1a\u5229\u7528Cookie\u6765\u4fdd\u6301\u7528\u6237\u7684\u4f1a\u8bdd\u72b6\u6001\uff0c\u4f7f\u670d\u52a1\u5668\u8bef\u4ee5\u4e3a\u6076\u610f\u8bf7\u6c42\u662f\u7528\u6237\u53d1\u9001\u7684\u5408\u6cd5\u8bf7\u6c42\u3002<\/p>\n\n\n\n

\u5b89\u5168\u9632\u62a4<\/h2>\n\n\n\n

\u4e3a\u4e86\u4fdd\u62a4\u7528\u6237\u7684\u9690\u79c1\u548c\u5b89\u5168\uff0c\u6211\u4eec\u9700\u8981\u91c7\u53d6\u76f8\u5e94\u7684\u5b89\u5168\u63aa\u65bd\u6765\u9632\u8303Cookie\u5e26\u6765\u7684\u98ce\u9669\u3002\u8fd9\u4e9b\u63aa\u65bd\u5305\u62ec\uff1a<\/p>\n\n\n\n

\u8bbe\u7f6e\u5b89\u5168\u6807\u5fd7<\/strong>\uff1a\u786e\u4fddCookie\u53ea\u5728HTTPS\u8fde\u63a5\u4e2d\u4f20\u8f93\uff0c\u9632\u6b62\u6570\u636e\u5728\u4f20\u8f93\u8fc7\u7a0b\u4e2d\u88ab\u7a83\u53d6\u6216\u7be1\u6539\u3002<\/p>\n\n\n\n

\u4f7f\u7528HttpOnly\u6807\u5fd7<\/strong>\uff1a\u9632\u6b62\u5ba2\u6237\u7aef\u811a\u672c\u901a\u8fc7JavaScript\u8bbf\u95eeCookie\uff0c\u51cf\u5c11XSS\u653b\u51fb\u7684\u98ce\u9669\u3002<\/p>\n\n\n\n

\u9650\u5236Cookie\u7684\u8303\u56f4<\/strong>\uff1a\u901a\u8fc7\u8bbe\u7f6eCookie\u7684\u8def\u5f84\u548c\u57df\u540d\uff0c\u9650\u5236Cookie\u7684\u8bbf\u95ee\u8303\u56f4\uff0c\u53ea\u5141\u8bb8\u7279\u5b9a\u7684URL\u6216\u57df\u540d\u8bbf\u95eeCookie\u3002<\/p>\n\n\n\n

\u52a0\u5bc6\u548c\u7b7e\u540d<\/strong>\uff1a\u5bf9Cookie\u4e2d\u7684\u654f\u611f\u4fe1\u606f\u8fdb\u884c\u52a0\u5bc6\u548c\u7b7e\u540d\uff0c\u786e\u4fdd\u6570\u636e\u7684\u5b8c\u6574\u6027\u548c\u5b89\u5168\u6027\u3002<\/p>\n\n\n\n

\u5b9a\u671f\u66f4\u65b0Cookie<\/strong>\uff1a\u5b9a\u671f\u66f4\u65b0Cookie\u7684\u503c\u548c\u8fc7\u671f\u65f6\u95f4\uff0c\u51cf\u5c11\u653b\u51fb\u8005\u5229\u7528\u65e7\u7684Cookie\u8fdb\u884c\u653b\u51fb\u7684\u673a\u4f1a\u3002<\/p>\n\n\n\n

\u8ba4\u8bc1\u673a\u5236<\/h2>\n\n\n\n

\u5728Web\u5e94\u7528\u4e2d\uff0c\u8ba4\u8bc1\u673a\u5236\u662f\u786e\u4fdd\u7528\u6237\u8eab\u4efd\u5408\u6cd5\u6027\u7684\u91cd\u8981\u624b\u6bb5\u3002Cookie\u4f5c\u4e3a\u8ba4\u8bc1\u673a\u5236\u7684\u4e00\u90e8\u5206\uff0c\u53ef\u4ee5\u7528\u4e8e\u5b58\u50a8\u7528\u6237\u7684\u4f1a\u8bdd\u4fe1\u606f\u548c\u8eab\u4efd\u9a8c\u8bc1\u51ed\u8bc1\u3002\u901a\u8fc7\u9a8c\u8bc1Cookie\u4e2d\u7684\u4fe1\u606f\uff0c\u670d\u52a1\u5668\u53ef\u4ee5\u8bc6\u522b\u7528\u6237\u7684\u8eab\u4efd\uff0c\u5e76\u6388\u6743\u7528\u6237\u8bbf\u95ee\u76f8\u5e94\u7684\u8d44\u6e90\u3002\u7136\u800c\uff0c\u4e3a\u4e86\u786e\u4fdd\u8ba4\u8bc1\u673a\u5236\u7684\u5b89\u5168\u6027\uff0c\u6211\u4eec\u9700\u8981\u7ed3\u5408\u5176\u4ed6\u5b89\u5168\u63aa\u65bd\uff0c\u5982\u4f7f\u7528HTTPS\u534f\u8bae\u3001\u8bbe\u7f6e\u5f3a\u5bc6\u7801\u7b56\u7565\u3001\u542f\u7528\u53cc\u91cd\u8ba4\u8bc1\u7b49\u3002<\/p>\n\n\n\n

\u7efc\u4e0a\u6240\u8ff0\uff0cCookie\u4f5c\u4e3aWeb\u5f00\u53d1\u4e2d\u4e0d\u53ef\u6216\u7f3a\u7684\u4e00\u90e8\u5206\uff0c\u5728\u4e3a\u7528\u6237\u63d0\u4f9b\u4e2a\u6027\u5316\u4f53\u9a8c\u548c\u4fbf\u6377\u670d\u52a1\u7684\u540c\u65f6\uff0c\u4e5f\u5e26\u6765\u4e86\u4e00\u4e9b\u6f5c\u5728\u7684\u5b89\u5168\u98ce\u9669\u3002\u4e3a\u4e86\u4fdd\u62a4\u7528\u6237\u7684\u9690\u79c1\u548c\u5b89\u5168\uff0c\u6211\u4eec\u9700\u8981\u91c7\u53d6\u76f8\u5e94\u7684\u5b89\u5168\u63aa\u65bd\u6765\u9632\u8303\u8fd9\u4e9b\u98ce\u9669\u3002\u901a\u8fc7\u4e86\u89e3Cookie\u7684\u7ec4\u6210\u3001\u5de5\u4f5c\u539f\u7406\u548c\u5b89\u5168\u5a01\u80c1\uff0c\u6211\u4eec\u53ef\u4ee5\u66f4\u597d\u5730\u5229\u7528Cookie\u4e3aWeb\u5e94\u7528\u63d0\u4f9b\u66f4\u5b89\u5168\u3001\u66f4\u53ef\u9760\u7684\u670d\u52a1\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

\u5728\u6570\u5b57\u5316\u65f6\u4ee3\uff0c\u4e92\u8054\u7f51\u5df2\u6210\u4e3a\u6211\u4eec\u65e5\u5e38\u751f\u6d3b\u4e0d\u53ef\u6216\u7f3a\u7684\u4e00\u90e8\u5206\u3002\u5f53\u6211\u4eec\u6d4f\u89c8\u7f51\u9875\u3001\u5728\u7ebf\u8d2d\u7269\u6216\u767b\u5f55\u793e\u4ea4\u5a92\u4f53\u65f6\uff0c\u6709\u4e00\u4e2a\u5c0f\u5c0f\u7684\u6587\u672c\u6587\u4ef6\u2014\u2014Cookie\uff0c\u5728\u9ed8\u9ed8\u53d1\u6325\u7740\u91cd\u8981\u4f5c\u7528\u3002 \u7b80\u4ecb Cookie\u5728\u8ba1\u7b97\u673a\u9886\u57df\u4e2d\u5374\u626e\u6f14\u7740\u91cd\u8981\u7684\u89d2\u8272\u3002\u5b83\u662f\u4e00\u79cd\u7531\u670d\u52a1\u5668\u53d1\u9001\u5230\u7528\u6237\u6d4f…<\/p>\n","protected":false},"author":422,"featured_media":97768,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9192,9191],"tags":[],"topic":[],"class_list":["post-97795","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-shuyu","category-baike"],"_links":{"self":[{"href":"https:\/\/www.073980.com\/wp-json\/wp\/v2\/posts\/97795","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.073980.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.073980.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.073980.com\/wp-json\/wp\/v2\/users\/422"}],"replies":[{"embeddable":true,"href":"https:\/\/www.073980.com\/wp-json\/wp\/v2\/comments?post=97795"}],"version-history":[{"count":1,"href":"https:\/\/www.073980.com\/wp-json\/wp\/v2\/posts\/97795\/revisions"}],"predecessor-version":[{"id":97797,"href":"https:\/\/www.073980.com\/wp-json\/wp\/v2\/posts\/97795\/revisions\/97797"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.073980.com\/wp-json\/wp\/v2\/media\/97768"}],"wp:attachment":[{"href":"https:\/\/www.073980.com\/wp-json\/wp\/v2\/media?parent=97795"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.073980.com\/wp-json\/wp\/v2\/categories?post=97795"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.073980.com\/wp-json\/wp\/v2\/tags?post=97795"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.073980.com\/wp-json\/wp\/v2\/topic?post=97795"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}