{"id":85294,"date":"2020-04-01T21:31:10","date_gmt":"2020-04-01T13:31:10","guid":{"rendered":"http:\/\/4563.org\/?p=85294"},"modified":"2020-05-16T18:00:42","modified_gmt":"2020-05-16T10:00:42","slug":"%e5%85%b3%e4%ba%8e%e6%b5%8f%e8%a7%88%e5%99%a8%e7%99%bb%e5%bd%95%e7%8a%b6%e6%80%81%e7%9a%84%e4%bf%9d%e5%ad%98","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=85294","title":{"rendered":"\u5173\u4e8e\u6d4f\u89c8\u5668\u767b\u5f55\u72b6\u6001\u7684\u4fdd\u5b58"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  \u5173\u4e8e\u6d4f\u89c8\u5668\u767b\u5f55\u72b6\u6001\u7684\u4fdd\u5b58               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : zxc1234 <\/span>  <span><i><\/i> 7<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u9762\u8bd5\u88ab\u95ee\u5230\u76f8\u5173-\u6ca1\u7b54\u597d\uff0c\u6302\u4e86<\/p>\n<p>\u95ee\uff1a\u6d4f\u89c8\u5668\u662f\u600e\u4e48\u4fdd\u6301\u767b\u5f55\u72b6\u6001\u7684\uff0c\u5c31\u662f\u4f60\u767b\u5f55\u4e00\u6b21\u540e\u8fc7\u6bb5\u65f6\u95f4\u4e0d\u7528\u518d\u767b\u5f55<\/p>\n<p>\u7b54\uff1a\u767b\u5f55\u7684\u65f6\u5019\uff0c\u7528\u6237\u8f93\u5165\u7528\u6237\u540d\u5bc6\u7801\uff0c\u4f1a\u8d70\u5230\u516c\u53f8\u7684\u7edf\u4e00\u9a8c\u8bc1\u4e2d\u5fc3 portal\uff0c\u9a8c\u8bc1\u6210\u529f\uff0c\u4f1a\u8fd4\u56de\u4e00\u4e2a token\uff0c<\/p>\n<p>\u7528\u6237\u6bcf\u6b21\u8bf7\u6c42\u6216\u8005\u5237\u65b0\u7f51\u9875\u7684\u65f6\u5019\u4f1a\u643a\u5e26\u8fd9\u4e2a token\uff0c\u7136\u540e\u8d70\u5230 portal \u9a8c\u8bc1\u4e2d\u5fc3\uff0c\u53ea\u8981 token \u6ca1\u8fc7\u671f\uff0c\u7528\u6237\u5c31\u4e0d\u7528\u91cd<\/p>\n<p>\u65b0\u767b\u5f55\u3002<\/p>\n<p>\u5927\u4f6c\u4eec\u80fd\u5e2e\u6211\u770b\u770b\u6211\u54ea\u91cc\u7b54\u9519\u4e86\uff0c\u6216\u8005\u600e\u4e48\u7b54\u6bd4\u8f83\u597d\uff0c\u591a\u8c22\uff01<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>10<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"1411946\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : yuzo555 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4ed6\u662f\u95ee\u6d4f\u89c8\u5668\uff0c\u4e0d\u662f\u95ee\u4f60\u670d\u52a1\u7aef\u5b9e\u73b0\u673a\u5236\u3002<br \/>\u6d4f\u89c8\u5668\u5c31\u662f\u5bf9 Cookie \u7684\u5904\u7406\u5457                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1411947\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : zxc1234 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @yuzo555 cookie \uff1f\u4e0d\u662f token \u5417\uff1f token\uff0ccookie\uff0csession \u6211\u641e\u6655\u4e86                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1411948\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : superrichman <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             token \u5b58\u5728 cookie \u91cc\uff0c\u968f\u8bf7\u6c42\u4e00\u8d77\u4f20\u8f93                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1411949\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : vzyw <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             session \u662f\u540e\u7aef\u7684\u6982\u5ff5\uff0csession \u672c\u8d28\u76ee\u7684\u5c31\u662f\u540e\u7aef\u9700\u8981\u533a\u5206\u51fa\u6bcf\u6b21\u8bf7\u6c42\u662f\u54ea\u4e2a\u7528\u6237\u4ea7\u751f\u7684\u3002\u7528 token \u7684\u60c5\u51b5\u4e0b\uff0c\u5c31\u662f\u627e\u5230\u8fd9\u4e2a token \u5bf9\u5e94\u7684\u7528\u6237\uff0c\u7528 cookie \u5c31\u662f\u627e\u5230\u8fd9\u4e2a cookie \u5bf9\u5e94\u7684\u7528\u6237\uff0ctoken \u3001cookie \u672c\u8d28\u90fd\u662f\u4e00\u4e32\u5b57\u7b26\u4e32\uff0c\u4e00\u822c\u505a\u6cd5\u662f\u540e\u7aef\u5728 redis \u91cc\u5b58\u6bcf\u4e2a tokensession \u5bf9\u5e94\u7684 user_id<\/p>\n<p>\u524d\u540e\u7aef\u5206\u79bb\u7684\u60c5\u51b5\u4e0b\uff0ctoken \u4e00\u822c\u662f\u524d\u7aef\u5b58\u5728 localstorage \u4e2d \uff0c\u5728\u8fdb\u884c xhr \u8bf7\u6c42\u65f6\u653e\u5728 herder \u7684\u4e00\u4e2a\u5b57\u6bb5\u91cc\u9762\uff0c\u4e00\u822c\u662f authorization \u5b57\u6bb5<\/p>\n<p>\u975e\u5206\u79bb\u7684\u60c5\u51b5\u4e0b\u4e00\u822c\u7528 cookie\uff0c\u8fd9\u65f6\u4e5f\u57fa\u672c\u4e0a\u6ca1\u6709 xhr \u7c7b\u578b\u7684\u8bf7\u6c42\uff0c\u4e5f\u6ca1\u6709\u8de8\u57df\u8bf7\u6c42\uff0c\u6240\u4ee5 cookie \u4f1a\u968f\u7740 get \u6216\u8005 post \u4e00\u540c\u63d0\u4ea4\u5230\u540e\u7aef<\/p>\n<p>\u8de8\u57df\u8bf7\u6c42 \/xhr \u7c7b\u578b\u8bf7\u6c42\u4e5f\u53ef\u4ee5\u8bbe\u7f6e cookie \u5e76\u4e14\u53ef\u4ee5\u81ea\u52a8\u5e26\u4e0a cookie\uff0c\u5177\u4f53\u5185\u5bb9\u8981\u67e5\u4e00\u4e0b\u6587\u6863\uff0c\u5fd8\u8bb0\u4e86                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1411950\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : also24 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div> <img decoding=\"async\" src=\"http:\/\/4563.org\/wp-content\/uploads\/2020\/05\/92IL9xOI-8.jpeg\" alt=\"\u5173\u4e8e\u6d4f\u89c8\u5668\u767b\u5f55\u72b6\u6001\u7684\u4fdd\u5b58\"> \u53c8\u5230\u4e86\u642c\u51fa\u8fd9\u7bc7\u6587\u7ae0\u7684\u65f6\u5019\u4e86<\/p>\n<p>https:\/\/www.v2ex.com\/t\/656457                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1411951\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : darknoll <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5e94\u8be5\u662f\u56de\u7b54 cookie \u6216\u8005 localstorage \u8fd9\u4e9b                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1411952\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : also24 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4e0d\u7ba1\u662f\u7eaf\u7cb9\u7684 token \u673a\u5236\uff0c\u4ea6\u6216\u8005\u5404\u7c7b Session \u673a\u5236\uff0c\u5176\u672c\u8eab\u7684\u76ee\u7684\u90fd\u662f\u4e3a\u4e86\u5bf9\u7528\u6237\u8fdb\u884c\u8bc6\u522b\u6216\u9274\u6743\u3002<br \/>\u90a3\u4e48\u6838\u5fc3\u5173\u6ce8\u70b9\u5c31\u4e09\u4e2a\u90e8\u5206\uff1a<br \/>&#8211; \u7528\u4ec0\u4e48\u4e1c\u897f\u3001\u4ec0\u4e48\u65b9\u5f0f\u6765\u8fdb\u884c\u8bc6\u522b\u9274\u6743<br \/>&#8211; \u7528\u6765\u8bc6\u522b\u9274\u6743\u7684\u8fd9\u4e2a\u4e1c\u897f\uff0c\u5b58\u50a8\u5728\u5ba2\u6237\u7aef\u4ec0\u4e48\u4f4d\u7f6e<br \/>&#8211; \u5ba2\u6237\u7aef\u5982\u4f55\u5c06\u8fd9\u4e2a\u4e1c\u897f\u53d1\u9001\u7ed9\u670d\u52a1\u7aef<\/p>\n<p>\u4ee5\u4e0b\uff0c\u662f\u5404\u79cd\u4e0d\u540c\u673a\u5236\u4e2d\uff0c\u7528\u6765\u8bc6\u522b\u9274\u6743\u6240\u7528\u7684 [\u51ed\u636e] \uff1a<br \/>Token \uff08\u4e5f\u5305\u62ec JWT \u7b49\u7279\u5b9a\u534f\u8bae\uff09<br \/>Session-ID \uff08 Server Side Session \uff09<br \/>Session-Data \uff08 Client Side Session \uff09 <br \/>\u7b49<\/p>\n<p>\u4ee5\u4e0b\uff0c\u662f\u53ef\u4ee5\u7528\u6765\u5b58\u50a8\u4e0a\u8ff0\u51ed\u636e\u7684\u4ecb\u8d28\uff1a<br \/>Cookie<br \/>localStorage \/ sessionStorage <br \/>URL \/ HTML <br \/>\u7b49<\/p>\n<p>\u4ee5\u4e0b\uff0c\u662f\u7528\u6765\u53d1\u9001\u4e0a\u8ff0\u51ed\u636e\u7684\u673a\u5236\uff1a<br \/>Cookie \u81ea\u52a8\u643a\u5e26\uff08\u8fd9\u662f Cookie \u7279\u6b8a\u7684\u4e00\u70b9\uff0c\u65e2\u662f\u5b58\u50a8\u5bb9\u5668\uff0c\u4e5f\u662f\u53d1\u9001\u673a\u5236\uff09<br \/>\u81ea\u5df1\u5728 Ajax \u8bf7\u6c42\u4e2d\u52a0 Header \u6216\u52a0\u5176\u5b83\u5b57\u6bb5<br \/>\u76f4\u63a5\u52a0\u5728 Request URL \u6216 Form \u4e0a <br \/>\u7b49                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1411953\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : jsisjs20130824 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             1.cookie \u5462\uff0c\u5c31\u662f\u8fd4\u56de\u5934\u6709\u4e2a set-cookie\uff0c\u8ba9\u6d4f\u89c8\u5668\u4fdd\u5b58 cookie\uff0ccookie \u662f\u4fdd\u5b58\u5728\u6d4f\u89c8\u5668<br \/>2.session \u5462\u662f\u6d4f\u89c8\u5668\u548c\u670d\u52a1\u7aef\u90fd\u4fdd\u5b58\uff0c\u670d\u52a1\u7aef\u7ed9\u4e00\u4e2a sessionid \u5b58 cookie,\u4e0b\u6b21\u8bf7\u6c42\u5e26\u4e0a\u8fd9\u4e2a cookie,\u670d\u52a1\u7aef\u62ff\u7740 sessionid \u53bb\u6570\u636e\u5e93\u6216\u8005\u7f13\u5b58\u533a\u67e5\uff0c\u8fd9\u79cd session \u65b9\u6848\u662f\u4f9d\u8d56\u4e8e cookie<br \/>3.token \u5c31\u662f\u5b58\u5728\u6d4f\u89c8\u5668\u7684 localstorage\uff0c\u4e0b\u6b21\u8bf7\u6c42\u5e26\u4e0a\u8fd9\u4e2a token,\u670d\u52a1\u7aef\u518d\u53bb\u5b58\u50a8\u4e2d\u627e token \u786e\u5b9a\u7528\u6237<br \/>4.\u8fd8\u6709\u4e00\u79cd token\uff0c\u53eb jwt\uff0c\u548c cookie \u5f88\u50cf\uff0c\u4e5f\u662f\u5b58\u6d4f\u89c8\u5668\uff0c\u6bd4\u5982 localstorage\uff0c\u4f46\u662f\u5b58\u6d4f\u89c8\u5668\u7684\u8bdd\uff0c\u670d\u52a1\u7aef\u5c31\u6ca1\u529e\u6cd5\u628a\u4ed6 revoke \u6389\uff0c\u4e5f\u5c31\u53d6\u6d88\uff0c\u6ca1\u529e\u6cd5\u9000\u51fa\u767b\u5f55<br \/>\u6b64\u5916\u8fd8\u6709 sessionstorage,VUE \u8fd8\u6709\u4e2a vuex \u72b6\u6001\u5b58\u50a8<br \/>\u7136\u4f9d\u8d56 cookie \u7684 session \u65b9\u6848\u4e0d\u597d\u89e3\u51b3\u8de8\u57df\u7684\u95ee\u9898\uff0c\u6bd4\u5982\u4f60\u7684 cookie \u662f\u8bbe\u7f6e\u5728\u8fd9\u4e2a\u57df\u4e0b\u9762\u7684\uff0c\u90a3\u8bf7\u6c42\u53e6\u5916\u4e00\u4e2a\u57df\uff0c\u4e0d\u4f1a\u5e26\u4e0a\u8fd9\u4e2a cookie\uff0c\u6216\u8005\u4f60\u8981\u7528 js \u53bb\u64cd\u4f5c\u8fd9\u4e2a\u57df\uff08\u5f00\u59cb\u80e1\u8bf4\u516b\u9053\uff09\uff0c\u90a3\u4f60\u7684 cookie \u5c31\u4e0d\u80fd\u662f http only<br \/>\u7136\u540e sessionstorage \u6211\u8fd8\u4e0d\u4f1a\uff0c\u4f60\u53bb\u767e\u5ea6\u4e00\u4e0b\uff0c\u7136\u540e\u544a\u8bc9\u6211\uff0c\u963f\u91cc\u560e\u591a                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1411954\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : xuanbg <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             4 \u6b63\u89e3\uff0c\u6bd4\u8f83\u5408\u7406\u7684\u505a\u6cd5\u662f\u5b58 localstorage\uff0c\u6bd5\u7adf cookie \u662f\u6bcf\u6b21\u8bf7\u6c42\u90fd\u4f1a\u5e26\u7740\u8d70\u7684\uff0c\u4e00\u6765\u6d6a\u8d39\u6d41\u91cf\uff0c\u4e8c\u6765\u4f1a\u66b4\u9732\u5728\u7f51\u7edc\u4e0a\uff0c\u6ca1\u6709\u5b58\u672c\u5730\u5b89\u5168\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1411955\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : also24 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u53e6\u5916\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u975e\u5e38\u975e\u5e38\u591a\u7684\u5173\u4e8e Session \u7684\u6587\u7ae0\u90fd\u4f1a\u51fa\u73b0\u4ee5\u4e0b\u8bef\u89e3\uff1a<br \/>1 \u3001\u5c06 Server Side Session \u5f53\u6210\u4e86 Session \u673a\u5236\u7684\u5168\u90e8\uff0c\u8bef\u4ee5\u4e3a Session Data \u4e00\u5b9a\u5b58\u50a8\u5728\u670d\u52a1\u7aef\u3002<br \/>2 \u3001\u5c06 Cookie \u5f53\u6210\u4e86 Session-ID \u7684\u552f\u4e00\u5b58\u50a8\u4f4d\u7f6e\uff0c\u8bef\u4ee5\u4e3a Session \u673a\u5236\u548c Cookie \u662f\u7ed1\u5b9a\u5173\u7cfb\u3002<br \/>3 \u3001\u5c06 JWT \u5f53\u6210\u4e86 Client Side Session \u7684\u552f\u4e00\u5b9e\u73b0\uff0c\u8bef\u4ee5\u4e3a JWT \u548c Session \u673a\u5236\u4e92\u4e3a\u5bf9\u624b\u5173\u7cfb\u3002<\/p>\n<p>\/\/ \u5f53\u7136\uff0c\u5f88\u591a\u9762\u8bd5\u5b98\u81ea\u5df1\u5176\u5b9e\u4e5f\u5b58\u5728\u8fd9\u6837\u7684\u8bef\u89e3\u3002\u53ea\u662f\u4e3a\u4e86\u9762\u8bd5\u7684\u8bdd\uff0c\u5012\u4e5f\u662f\u6ca1\u592a\u5927\u6240\u8c13\u3002<br \/>\/\/ and \u5176\u5b9e\u8fd9\u91cc\u5df2\u7ecf\u597d\u51e0\u4e2a\u670b\u53cb\u51fa\u73b0\u76f8\u5e94\u7684\u8bef\u89e3\u4e86\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>\u5173\u4e8e\u6d4f\u89c8\u5668\u767b\u5f55\u72b6\u6001\u7684\u4fdd\u5b58 \u8cc7\u6df1\u5927\u4f6c&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/85294"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=85294"}],"version-history":[{"count":1,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/85294\/revisions"}],"predecessor-version":[{"id":85296,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/85294\/revisions\/85296"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=85294"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=85294"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=85294"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}