{"id":266,"date":"2008-12-12T11:15:52","date_gmt":"2008-12-12T03:15:52","guid":{"rendered":""},"modified":"2014-02-27T23:01:23","modified_gmt":"2014-02-27T15:01:23","slug":"cookies%e5%b8%b8%e7%94%a8%e5%91%bd%e4%bb%a4%e7%ae%80%e4%bb%8b","status":"publish","type":"post","link":"http:\/\/www.xiaoyebailong.com\/index.php\/2008\/12\/12\/266.htm","title":{"rendered":"Cookies\u5e38\u7528\u547d\u4ee4\u7b80\u4ecb"},"content":{"rendered":"<p>Cookies\u5e38\u7528\u547d\u4ee4\u7b80\u4ecb<br \/>\n\u4ec0\u4e48\u662fCookies\uff1fCookies\u662f\u6570\u636e\u5305\uff0c\u53ef\u4ee5\u8ba9\u7f51\u9875\u5177\u6709\u8bb0\u5fc6\u529f\u80fd\uff0c\u5728\u67d0\u53f0\u7535\u8111\u4e0a\u8bb0\u5fc6\u4e00\u5b9a\u7684\u4fe1\u606f\u3002Cookies\u7684\u5de5\u4f5c\u539f\u7406\u662f\uff0c\u7b2c\u4e00\u6b21\u7531\u670d\u52a1\u5668\u7aef\u5199\u5165\u5230\u5ba2\u6237\u7aef\u7684\u7cfb\u7edf\u4e2d\u3002\u4ee5\u540e\u6bcf\u6b21\u8bbf\u95ee\u8fd9\u4e2a\u7f51\u9875\uff0c\u90fd\u662f\u5148\u7531\u5ba2\u6237\u7aef\u5c06Cookies\u53d1\u9001\u5230\u670d\u52a1\u5668\u7aef\uff0c\u518d\u7531\u670d\u52a1\u5668\u7aef\u8fdb\u884c\u5224\u65ad\uff0c\u7136\u540e\u518d\u4ea7\u751fHTML\u4ee3\u7801\u8fd4\u56de\u7ed9\u5ba2\u6237\u7aef\uff0c\u8fd9\u662f\u4e00\u4e2a\u5f88\u91cd\u8981\u7684\u539f\u7406\u3002 <br \/>\n&nbsp; <br \/>\nCookies\u5728ASP\u4e2d\u7684\u6700\u5e38\u7528\u7684\u65b9\u6cd5\uff0c\u8bf7\u505a\u597d\u7b14\u8bb0\uff1a <br \/>\n&nbsp; <br \/>\n1.\u5982\u4f55\u5199\u5165Cookies\uff1f<\/p>\n<p>Response.Cookies(&quot;\u5b57\u6bb5\u540d&quot;)=\u53d8\u91cf\u6216\u5b57\u7b26\u4e32\uff0c\u4f8b\u5982\uff1a <br \/>\nResponse.Cookies(&quot;name&quot;)=&quot;<a rel=\"nofollow\" href=\"http:\/\/www.evilangel.cn\">www.evilangel.cn<\/a>&quot; <br \/>\n&nbsp; <br \/>\n2.\u5982\u4f55\u8bbe\u7f6eCookies\u65f6\u95f4\uff1f<\/p>\n<p>&#8216;Expires\u5c5e\u6027: \u6307\u5b9a\u4e86\u8be5cookie\u7684\u8fc7\u671f\u65f6\u95f4; <br \/>\nResponse.Cookies(&quot;\u5b57\u6bb5\u540d&quot;).Expires = \u65f6\u95f4\u51fd\u6570+N\uff0c\u4f8b\u5982\uff1a <br \/>\nResponse.Cookies(&quot;name&quot;).Expires = date+1&nbsp;&nbsp; &#8216;\u8868\u793aCookies\u4fdd\u5b581\u5929\u3002 <br \/>\nResponse.Cookies(&quot;name&quot;).Expires = Hour+8&nbsp;&nbsp; &#8216;\u8868\u793aCookies\u4fdd\u5b588\u5c0f\u65f6\u3002 <br \/>\nresponse.cookies(&quot;name&quot;).Expires = &quot;2006\/1\/20&quot;&nbsp;&nbsp; &#8216;\u8868\u793aCookies\u52302006\/1\/20\u8fc7\u671f\u3002 <br \/>\n&nbsp; <br \/>\n3.\u5176\u5b83<\/p>\n<p>response.cookies(&quot;name&quot;).Domain=&quot;asp.com&quot; <br \/>\n&#8216;Domain\u5c5e\u6027: \u6307\u5b9a\u4e86\u8be5cookie\u53ea\u80fd\u53d1\u9001\u5230asp.com\u8fd9\u4e2a\u57df\u4e2d; <br \/>\nresponse.cookies(&quot;name&quot;).Path=&quot;\/www\/home\/&quot; <br \/>\n&#8216;Path\u5c5e\u6027: \u6307\u5b9a\u4e86\u8be5cookie\u53ea\u80fd\u53d1\u9001\u5230\u8def\u5f84\/www\/home\/\u7684\u8bf7\u6c42\u4e2d <br \/>\nresponse.cookies(&quot;name&quot;).Secure=True <br \/>\n&#8216;Secure\u5c5e\u6027: \u6307\u5b9a\u5728\u6570\u636e\u4f20\u8f93\u8fc7\u7a0b\u4e2d\u91c7\u7528\u52a0\u5bc6\u7b97\u6cd5 <br \/>\n&nbsp; <br \/>\n4.\u5728\u4ee5\u5f80\u7684ASP\u6559\u7a0b\u4e2d\uff0c\u5f88\u5c11\u6709\u4ecb\u7ecdCookies\u9000\u51fa\u7684\u65b9\u6cd5\u3002\u5728&ldquo;\u9000\u51fa&rdquo;\u8fd9\u4e2aASP\u9875\u4e2d\u53ef\u4ee5\u8fd9\u6837\u5199\uff1a<\/p>\n<p>Response.Cookies(&quot;\u5b57\u6bb5\u540d&quot;)=&quot;&quot; <br \/>\n\u4e4b\u540e\uff0c\u5728\u5ba2\u6237\u7aef\u7684\u6d4f\u89c8\u5668\u5c31\u6e05\u9664\u4e86Cookies\uff0c\u5e76\u4e14Cookies\u6587\u4ef6\u4f1a\u6d88\u5931\u3002\u6ce8\u610f\u6709\u591a\u5c11\u4e2a\u5b57\u6bb5\uff0c\u5c31\u8981\u5199\u591a\u5c11\u53e5\u6765\u6e05\u9664\u3002 <br \/>\n&nbsp; <br \/>\n5.\u5982\u4f55\u8bfb\u53d6Cookies\uff1f<\/p>\n<p>\u53d8\u91cf\u540d = Request.Cookies(&quot;\u5b57\u6bb5\u540d&quot;)\uff0c\u4f8b\u5982\uff1a <br \/>\nname = Request.Cookies(&quot;name&quot;) <br \/>\n\u5982\u679c\u7f51\u9875\u4e2d\u5199\u5165&lt;%=name%&gt;\u8fd9\u53e5\uff0c\u5219\u4f1a\u663e\u793a&ldquo;www.evilangl.cn&rdquo;\u3002 <br \/>\n\u4e5f\u53ef\u4ee5\u8fd9\u6837\u76f4\u63a5\u8bfb\u53d6Cookies\uff0c&lt;%=Request.Cookies(&quot;name&quot;)%&gt; <br \/>\n&nbsp; <br \/>\nCookies\u662f\u5c5e\u4e8eSession\u5bf9\u8c61\u7684\u4e00\u79cd\u3002\u4f46\u6709\u4e0d\u540c\uff0cCookies\u4e0d\u4f1a\u5360\u670d\u52a1\u5668\u8d44\u6e90\uff1b\u800c&ldquo;Session&rdquo;\u5219\u4f1a\u5360\u7528\u670d\u52a1\u5668\u8d44\u6e90\u3002\u6240\u4ee5\uff0c\u5c3d\u91cf\u4e0d\u8981\u4f7f\u7528Session\uff0c\u800c\u4f7f\u7528Cookies\u3002 <br \/>\n&nbsp; <br \/>\n\u4f8b\u5b50\uff1a <br \/>\n&nbsp; <br \/>\n&lt;% <br \/>\n&#8216;\u5237\u65b0\u9875\u9762\u6216\u518d\u6b21\u6253\u5f00\u6b64\u9875\u9762\u65f6\uff0c\u663e\u793a\u7684\u987a\u5e8f\u5c06\u98a0\u5012\uff0c\u4e3a\u4ec0\u4e48\uff1f\uff1f <br \/>\nresponse.cookies(&quot;TestCookies1&quot;)(&quot;Name&quot;)=&quot;Test Cookies 1&quot; <br \/>\nresponse.cookies(&quot;TestCookies1&quot;)(&quot;Name&quot;)=&quot;TestCookies1&quot; <br \/>\nresponse.cookies(&quot;TestCookies1&quot;).path=&quot;\/&quot; <br \/>\nresponse.cookies(&quot;TestCookies1&quot;).expires=#2004\/7\/25# <br \/>\nresponse.cookies(&quot;TestCookies2&quot;)=&quot;Test Cookies 2&quot; <br \/>\nresponse.cookies(&quot;TestCookies2&quot;).path=&quot;\/&quot; <br \/>\nresponse.cookies(&quot;TestCookies2&quot;).expires=#2004\/7\/25# <br \/>\n%&gt; <br \/>\n&lt;html&gt; <br \/>\n&lt;head&gt; <br \/>\n&lt;title&gt;Cookie\u7684\u4f7f\u7528&#8211;\u521b\u5efa\u3001\u8bfb\u53d6cookies\u503c&lt;\/title&gt; <br \/>\n&lt;\/head&gt; <br \/>\n&lt;body&gt; <br \/>\n&lt;% <br \/>\n&#8216;\u5229\u7528\u5faa\u73af\u8bfb\u53d6TestCookies1 <br \/>\nFor each cookiesname in request.cookies <br \/>\n&nbsp;&nbsp;&nbsp;&nbsp; if request.cookies(cookiesname).haskeys then <br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for each keycookies in request.cookies(cookiesname) <br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; response.write keycookies &amp; &quot;\u7684\u5185\u5bb9\u503c\u662f: &quot; &amp; request.cookies(cookiesname) &amp; &quot;&lt;br&gt;&quot; <br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; next <br \/>\n&nbsp;&nbsp;&nbsp;&nbsp; else <br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; response.write cookiesname &amp; &quot;\u7684\u5185\u5bb9\u503c\u662f: &quot; &amp; request.cookies(cookiesname) &amp; &quot;&lt;br&gt;&quot; <br \/>\n&nbsp;&nbsp;&nbsp;&nbsp; end if <br \/>\nnext <br \/>\n%&gt; <br \/>\n&lt;\/body&gt; <br \/>\n&lt;\/html&gt;<br \/>\n&nbsp;<br \/>\n&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Cookies\u5e38\u7528\u547d\u4ee4\u7b80\u4ecb \u4ec0\u4e48\u662fCookies\uff1fCookies\u662f\u6570\u636e\u5305\uff0c\u53ef\u4ee5\u8ba9\u7f51\u9875\u5177\u6709\u8bb0\u5fc6\u529f\u80fd\uff0c\u5728\u67d0\u53f0\u7535\u8111\u4e0a\u8bb0\u5fc6\u4e00\u5b9a\u7684\u4fe1\u606f\u3002Cookies\u7684\u5de5\u4f5c\u539f\u7406\u662f\uff0c\u7b2c\u4e00\u6b21\u7531\u670d\u52a1\u5668\u7aef\u5199\u5165\u5230\u5ba2\u6237\u7aef\u7684\u7cfb\u7edf\u4e2d\u3002\u4ee5\u540e\u6bcf\u6b21\u8bbf\u95ee\u8fd9\u4e2a\u7f51\u9875\uff0c\u90fd\u662f\u5148\u7531\u5ba2\u6237\u7aef\u5c06Cooki&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"topic":[],"class_list":["post-266","post","type-post","status-publish","format-standard","hentry","category-technology"],"_links":{"self":[{"href":"http:\/\/www.xiaoyebailong.com\/index.php\/wp-json\/wp\/v2\/posts\/266","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.xiaoyebailong.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.xiaoyebailong.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.xiaoyebailong.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.xiaoyebailong.com\/index.php\/wp-json\/wp\/v2\/comments?post=266"}],"version-history":[{"count":1,"href":"http:\/\/www.xiaoyebailong.com\/index.php\/wp-json\/wp\/v2\/posts\/266\/revisions"}],"predecessor-version":[{"id":66118,"href":"http:\/\/www.xiaoyebailong.com\/index.php\/wp-json\/wp\/v2\/posts\/266\/revisions\/66118"}],"wp:attachment":[{"href":"http:\/\/www.xiaoyebailong.com\/index.php\/wp-json\/wp\/v2\/media?parent=266"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.xiaoyebailong.com\/index.php\/wp-json\/wp\/v2\/categories?post=266"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.xiaoyebailong.com\/index.php\/wp-json\/wp\/v2\/tags?post=266"},{"taxonomy":"topic","embeddable":true,"href":"http:\/\/www.xiaoyebailong.com\/index.php\/wp-json\/wp\/v2\/topic?post=266"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}