Thursday, 15 November 2018

Cannot modify header information - PHP











I have built a website with lots of functions supported by programming. As the website is growing bigger, I found when doing photo upload, login, the following errors appear:-




Warning: session_regenerate_id() [function.session-regenerate-id]: Cannot regenerate session id - headers already sent in /var/www/web92/web/li/sli.php on line 63




Warning: Cannot modify header information - headers already sent by (output started at /var/www/web92/web/index826.php:62) in /var/www/web92/web/li/sli.php on line 72




I found adding ob_start(); at the very beginning of index can solve the problem, however, I would like to learn, if the running of php codes may have length limit.


Answer



The message




output started at /var/www/web92/web/index826.php:62





means that you have already written out content and the server has begun streaming the response to the client. You cannot modify the headers because they have already been sent.



Move the header-generating code to a point before the very first output is written.


No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...