在测试过程中发现 如果方法有echo 等函数输出到PHP的输出缓存中 存在  sessionID 不会放到http的请求头中  下次请求也就拿不到sessionid问题

问题的原因

代码位置:public/index.php

$response->send();

该方法代用方法   代码: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始终没有生效问题

最新文章

  1. c#比较两个List相等
  2. Linux(ubanto):可以ping通IP,但不能ping通域名
  3. Electron-使用Electron开发第一个应用
  4. 孙鑫MFC学习笔记2:C++回顾
  5. .net社区
  6. rails利用big_sitemap生成sitemap
  7. Java使用代理Proxy访问网络及其验证
  8. 世界级Oracle专家Jonathan Lewis:我很为DBA们的未来担心(图灵访谈)
  9. [0.0]Analysis of Baidu search engine
  10. PERL 脚本
  11. ios实现截屏(转)
  12. 上次的AJAX定时刷新多ID不正确,这次请教了高手之后补全
  13. VC++学习之一
  14. html5移动开发--js温馨提示
  15. C#函数式程序设计之泛型(下)
  16. iwlist等工具的移植
  17. VS2015安装提示出现“安装包丢失或损坏”解决方法
  18. vi/vim下tab的长度修改
  19. ROS_Kinetic_20 ROS基础补充
  20. Mono.Cecil

热门文章

  1. nyoj 55 懒省事的小明(priority_queue优先队列)
  2. [luoguP1196] 银河英雄传说(并查集)
  3. [BZOJ2594] [Wc2006]水管局长数据加强版(LCT + kruskal + 离线)
  4. 通过JQUERY获取SELECT OPTION中选中的值
  5. 洛谷 P2853 [USACO06DEC]牛的野餐Cow Picnic
  6. 17、Java并发性和多线程-避免死锁
  7. java中普通的顶级类是不能使用static关键字修饰的。只有内部类可以使用static修饰,也可以不使用staitc关键字修饰。
  8. 从一个简单的例子谈谈package与import机制
  9. ubuntu 建立加密分區及其安全刪除
  10. 选择排序(2)——堆排序(heap sort)