在测试过程中发现 如果方法有echo 等函数输出到php的输出缓存中 存在 sessionid 不会放到http的请求头中 下次请求也就拿不到sessionid问题
问题的原因
代码位置:public/index.php
$response->send();
闪睿企业网站管理系统是一套针对企业的网站管理系统。他高效、智能、友好易用。采用ASP.NET 2.0(C#),AJAX.NET 设计,系统架构优秀,高可用性设计,操作简单,功能强大,同时支持任意多语言,初次访问自动生成HTML,模板机制简单而灵活闪睿企业网站管理系统 2009 SP1 Build 090828 更新日志1.招贤纳士前台权限问题2.招贤纳士加入默认内容模版3.增加更多免费模版 后台登
0
该方法代用方法 代码:vendor/symfony/http-foundation/Response.php
/**
* Sends HTTP headers.
*
* @return $this */
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中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号