-3

Possible Duplicate:
PHP error: Cannot modify header information – headers already sent

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.

Community
  • 1
  • 1
Ham
  • 804
  • 3
  • 15
  • 25

3 Answers3

2

please ensure that

session_start() is called before outputing anything to the browser

refer notes in http://php.net/manual/en/function.session-start.php

Mithun Satheesh
  • 27,240
  • 14
  • 77
  • 101
1

session_start() should be called before any output to the page.

Incorrect

<?php
$calculation = 1 + 1;

echo $calculation;

session_start();
?>

Correct

<?php
$calculation = 1 + 1;

session_start();

echo $calculation;
?>

Notice that you can still run code before, but ensure it does not output anything to the browser before calling the session_start() function.

Luke
  • 22,826
  • 31
  • 110
  • 193
0

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.

Ishmaeel
  • 14,138
  • 9
  • 71
  • 83