php session_start()-phpDesigner

127 views Asked by At

I know this has been asked many times but my code works fine with no errors when it runs on the hosting company's server. I only get this error when I run it from phpDesigner:

PHP Warning: session_start(): Cannot send session cookie - headers already sent in C:\Development\PHP_Projects\BrothersNetLogger\index.php on line 3 PHP Stack trace: PHP 1. {main}() 

The index.php starts like this:

<?php
    ob_start();
    session_start();
?>

I have tried every fix suggested in the forum with no luck. It would seem that the problem is specific to phpDesigner. Any suggestions are welcome.

1

There are 1 answers

0
Rajib Ghosh On

ob_start — Turn on output buffering

If by default your output_buffering is Off and you have been unfortunate enough to send a single byte of data back to the client then your HTTP headers have already been sent. Which effectively prevents session_start() from passing the cookie header back to the client. By calling ob_start() you enable buffering and therefore delay sending http headers.Maybe you get PHP Warning: session_start(): Cannot send session cookie - headers already sent..

so you can try

<?php
    session_start();
    ob_start();

?>

instated of

?php
    ob_start();
    session_start();


?>

here is some useful link for you