Portal Home > Knowledgebase > Articles Database > Cannot send session cookie - headers already sent
Cannot send session cookie - headers already sent
Posted by 333halfevil, 12-31-2009, 09:36 PM |
Hi everyone. I am having trouble with this php. Any help is appreciated. Thanks
I keep getting these errors:
Here is a the code:
|
Posted by someone150, 01-01-2010, 07:35 AM |
session_start(); must be before any other output (html).
|
Posted by foobic, 01-01-2010, 07:38 AM |
You need to finish setting up your session data before anything goes out to the browser. So put all your form processing code in before that initial " |
Posted by someone150, 01-01-2010, 08:03 AM |
Actually, you just need to put session_start(); before other output. Session data can be set even after output, because they are on server side.
Another option is to use ob_start(); before session_start(); which allows you to set cookies, use header("Location: /"); anywhere in code.
|
Posted by 333halfevil, 01-01-2010, 10:08 AM |
Thank you for your help What a co-incidence exactly at the same time haha
I'm still having trouble with this though. After looking through it I could find nothing missing?
|
Posted by Neseema M M, 01-02-2010, 01:05 AM |
I too cannot find any error there.
Anyway change the quotes in the $_SERVER array and put it correctly so that PHP_SELF got printed in red color . I think it may cause the problem.
|
Posted by 333halfevil, 01-02-2010, 02:46 AM |
Thank you very much. It is now fixed
|
Add to Favourites Print this Article
Also Read