{"id":479,"date":"2010-07-25T09:12:11","date_gmt":"2010-07-25T09:12:11","guid":{"rendered":""},"modified":"2010-07-25T09:12:11","modified_gmt":"2010-07-25T09:12:11","slug":"479","status":"publish","type":"post","link":"https:\/\/www.poloo.org\/?p=479","title":{"rendered":"\u5982\u4f55\u8bbe\u7f6e SESSION \u7684\u8fc7\u671f\u65f6\u95f4"},"content":{"rendered":"<p>PHP \u4ee3\u7801\u4e3a\uff1a<\/p>\n<p>view sourceprint?\/\/Session_Start 30 minutes destroy&nbsp;&nbsp;<\/p>\n<p>$lifeTime = 1800;\/\/\u5355\u4f4d\uff1a\u79d2&nbsp;&nbsp;<\/p>\n<p>try&nbsp;&nbsp; <\/p>\n<p>{&nbsp;&nbsp;<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;session_start();&nbsp;&nbsp;<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;setcookie( session_name(), session_id(), time() + $lifeTime, &#8220;\/&#8221; );&nbsp;&nbsp;<\/p>\n<p>}&nbsp;&nbsp; <\/p>\n<p>catch ( Exception $e )&nbsp;&nbsp;<\/p>\n<p>{&nbsp;&nbsp;<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;session_set_cookie_params( $lifeTime );&nbsp;&nbsp;<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;session_start();&nbsp;&nbsp;<\/p>\n<p>}&nbsp;&nbsp;<\/p>\n<p>$_SESSION[&#8220;LOGIN&#8221;] = &#8220;OK&#8221;; <br \/>view sourceprint?&nbsp;&nbsp; <\/p>\n<p>\u76f8\u5173\u8bf4\u660e\uff1a<\/p>\n<p>view sourceprint?Session \u662f\u5982\u4f55\u6765\u5224\u65ad\u5ba2\u6237\u7aef\u7528\u6237\u7684\u5462\uff1f\u5b83\u662f\u901a\u8fc7 Session ID \u6765\u5224\u65ad\u7684\uff0c\u4ec0\u4e48\u662f Session ID\uff0c\u5c31\u662f\u90a3\u4e2a Session \u6587\u4ef6\u7684\u6587\u4ef6\u540d\uff0cSession ID \u662f\u968f\u673a\u751f\u6210\u7684\uff0c\u56e0\u6b64\u80fd\u4fdd\u8bc1\u552f\u4e00\u6027\u548c\u968f\u673a\u6027\uff0c\u786e\u4fdd Session \u7684\u5b89\u5168\u3002\u4e00\u822c\u5982\u679c\u6ca1\u6709\u8bbe\u7f6e Session \u7684\u751f\u5b58\u5468\u671f\uff0c\u5219 Session ID \u5b58\u50a8\u5728\u5185\u5b58\u4e2d\uff0c\u5173\u95ed\u6d4f\u89c8\u5668\u540e\u8be5 ID \u81ea\u52a8\u6ce8\u9500\uff0c\u91cd\u65b0\u8bf7\u6c42\u8be5\u9875\u9762\u540e\uff0c\u91cd\u65b0\u6ce8\u518c\u4e00\u4e2a Session ID\u3002&nbsp;&nbsp;<\/p>\n<p> \u3000\u3000\u5982\u679c\u5ba2\u6237\u7aef\u6ca1\u6709\u7981\u7528 Cookie\uff0c\u5219 Cookie \u5728\u542f\u52a8 Session \u4f1a\u8bdd\u7684\u65f6\u5019\u626e\u6f14\u7684\u662f\u5b58\u50a8 Session ID \u548c Session \u751f\u5b58\u671f\u7684\u89d2\u8272\u3002 <br \/>view sourceprint?Session \u8fd8\u63d0\u4f9b\u4e86\u4e00\u4e2a\u51fd\u6570 session_set_cookie_params(); \u6765\u8bbe\u7f6e Session \u7684\u751f\u5b58\u671f\u7684\uff0c\u8be5\u51fd\u6570\u5fc5\u987b\u5728 session_start() \u51fd\u6570\u8c03\u7528\u4e4b\u524d\u8c03\u7528\uff1a\u5982\u4e0a\u9762\u7684\u4ee3\u7801\u6240\u793a\u3002 <\/p>\n","protected":false},"excerpt":{"rendered":"<p>PHP \u4ee3\u7801\u4e3a\uff1a view sourceprint?\/\/Sessio&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18],"tags":[],"class_list":["post-479","post","type-post","status-publish","format-standard","hentry","category-Php"],"_links":{"self":[{"href":"https:\/\/www.poloo.org\/index.php?rest_route=\/wp\/v2\/posts\/479","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.poloo.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.poloo.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.poloo.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.poloo.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=479"}],"version-history":[{"count":0,"href":"https:\/\/www.poloo.org\/index.php?rest_route=\/wp\/v2\/posts\/479\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.poloo.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=479"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.poloo.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=479"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.poloo.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=479"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}