如何诊断错误:无法添加Cookie,标头已发送 [英] How to diagnose error : Unable to add cookies, header already sent

查看:91
本文介绍了如何诊断错误:无法添加Cookie,标头已发送的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


错误:无法添加Cookie,标题已发送。

Error : Unable to add cookies, header already sent.

有任何方式我可以有效地诊断以上错误。

我理解导致此错误的原因 - 当cookie发送到浏览器,如headers,html等发送后。

I would like to know if there is any way I can diagnose above error efficiently.
I understand the cause of this error - when cookies are being sent after something else has been sent to the browser such as headers, html etc.

有数百个文件,有成千上万行代码。如果任何人知道一个方法(即使第三方,它没有关系),这将帮助我找到哪些内容发送到浏览器之前的Cookie,所以我可以轻松地操纵这部分代码。我在找到导致此错误的实际地点或代码补丁时遇到问题。

There are hundreds of files with thousands of lines of codes. If anyone knows a method (even if 3rd party, it doesn't matter) that will help me to find which contents are sent to the browser before cookies so I can manipulate that part of code easily. I'm having trouble locating actual place or code patch causing this error.

通常这会发生在许多vBulletin用户,vB工作人员告诉你禁用mods /插件等,但我想知道任何有效的方法来找到问题位置。 <?php 等没有问题。

Generally this happens to many vBulletin users out there and vB staff tells you to disable mods/plugins etc. But i would like to know any efficient way to find problem location. There is no problem with <?php etc. etc.

推荐答案

在cookie设置点参考 header_sent()函数。 php函数header_sent()可以帮助您。

Refer to header_sent() function at point of cookie setting. php function header_sent() can help you.

bool headers_sent ([ string &$file [, int &$line ]] )

If the optional file and line parameters are set, headers_sent() will put the PHP source file name and line number where output started in the file and line variables.

这篇关于如何诊断错误:无法添加Cookie,标头已发送的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆