久久久久在线观看_又色又爽又黄的免费视频播放_一区中文字幕_日韩电影在线播放

今日焦點 焦點資訊 營銷之道 企業報道 淘寶運營 網站建設 軟件開發 400電話
  當前位置: 首頁 » 資訊 » 軟件開發 » 正文

Laravel 5.4 session 生效問題

放大字體  縮小字體 發布日期:2018-02-20  來源:企業800網  作者:新格網  瀏覽次數:578  【去百度看看】
在測試過程中發現 如果方法有echo 等函數輸出到PHP的輸出緩存中 存在 sessionID 不會放到http的請求頭中 下次請求也就拿不到sessionid問題

問題的原因

代碼位置:public/index.php

$response->send();

該方法代用方法 代碼:vendor/symfony/http-foundation/Response.php

    
    public function sendHeaders()
    {        // headers have already been sent by the developer
        if (headers_sent()) {            return $this;
        }        // headers
        foreach ($this->headers->allPreserveCaseWithoutcookies() as $name => $values) {            foreach ($values as $value) {                header($name.': '.$value, false, $this->statusCode);
            }
        }        // status
        header(sprintf('HTTP/%s %s %s', $this->version, $this->statusCode, $this->statusText), true, $this->statusCode);        // cookies
        foreach ($this->headers->getcookies() as $cookie) {            if ($cookie->isRaw()) {                setrawcookie($cookie->getName(), $cookie->getValue(), $cookie->getExpiresTime(), $cookie->getPath(), $cookie->getDomain(), $cookie->isSecure(), $cookie->isHttponly());
            } else {                setcookie($cookie->getName(), $cookie->getValue(), $cookie->getExpiresTime(), $cookie->getPath(), $cookie->getDomain(), $cookie->isSecure(), $cookie->isHttponly());
            }
        }        return $this;
    }

以前的原因出現在 headers_sent() 中

有興趣的同學可以測試一下 如果輸出緩存存在數據 (在方法使用echo 之類的函數有打印行為) headers_sent() 函數則返回ture

這樣就解釋了 在方法中存在打印的函數時候 你的session始終沒有生效問題

以上就是Laravel 5.4 session 生效問題的詳細內容,更多請關注php中文網其它相關文章!

 
關鍵詞: Laravel,session,問題
 
[ 資訊搜索 ]  [ 加入收藏 ]  [ 告訴好友 ]  [ 打印本文 ]  [ 違規舉報 ]  [ 關閉窗口 ]

 
0條 [查看全部]  相關評論

 
網站首頁 | 關于我們 | 聯系方式 | 使用協議 | 版權隱私 | 網站地圖 | 排名推廣 | 廣告服務 | 積分換禮 | 網站留言 | RSS訂閱 | 皖ICP備2021004516號-14
企業800網 · 提供技術支持