<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                [TOC] # 注意事項 我們知道,php的setcookie和header都可以設置cookie。但是使用header的時候,還有個注意事項:那就是header和setcookie之間的先后順序,甚至header和header之間的先后順序。 header("Set-Cookie:")會清除掉:本語句調用之前的,所有的header("Set-Cookie:")和setcookie(setrawcookie)的效果。見下面的例子,設置了四個cookie。但是實際上只有一個生效。因為另外三個被最后一個給沖掉了。 ~~~ header("Set-Cookie:cookie_name1_cp=" . urlencode("瀏覽器關閉失效")); setcookie("cookie_name1", "瀏覽器關閉失效"); setcookie("cookie_name3", "設置有效域名/https/httponly", time() + 3600*24, "/", $_SERVER['SERVER_NAME'], isset($_SERVER["HTTPS"]),true); header("Set-Cookie:cookie_name3_cp=" . urlencode("設置有效域名/https/httponly") . "; expires=" . gmstrftime("%a, %d-%b-%Y %H:%M:%S GMT", time() + 3600*24) . "; Max-Age=3600; path=/; domain= ".$_SERVER['SERVER_NAME']."; httponly"); ~~~ **解決問題方案一** 都使用setcookie函數來控制,那必是極好的,setcookie函數不會相互沖突。即使重名,只要重要信息不同,也是可以同時存在的。(也就是說,重名的話,存在替換的可能性)。 ~~~ setcookie("cookie_name1", "瀏覽器關閉失效"); setcookie("cookie_name1", "設置有效域名/https/httponly", time() + 3600*24, "/", $_SERVER['SERVER_NAME'], isset($_SERVER["HTTPS"]),true); ~~~ **解決問題方案二** 為header增加第二個參數,false。就是說: ~~~ header("Set-Cookie:xxxxxxxxxxxxxxxx",false); ~~~ 例如: ~~~ header("Set-Cookie:cookie_name3_cp=" . urlencode("設置有效域名/https/httponly") . "; expires=" . gmstrftime("%a, %d-%b-%Y %H:%M:%S GMT", time() + 3600*24) . "; Max-Age=3600; path=/; domain= ".$_SERVER['SERVER_NAME']."; httponly;"); header("Set-Cookie:cookie_name3_cp2=" . urlencode("設置有效域名/https/httponly") . "; expires=" . gmstrftime("%a, %d-%b-%Y %H:%M:%S GMT", time() + 3600*24) . "; Max-Age=3600; path=/; domain= ".$_SERVER['SERVER_NAME']."; httponly;",FALSE); ~~~ 這樣的話,使用了false參數的header就不會沖突掉原有的了。 具體可以參見header的php函數說明: ~~~ void header ( string $string [, bool $replace = true [, int $http_response_code ]] ) ~~~ 我們的false,設置的就是參數$replace,就是不替換已有同類型header的意思。注意是“同類型”。
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看