Session handling

F

Flamin_Squirrel

Guest
On using the session_start(); line on a php page, i get the 2 following error lines...

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/virtual/site99/fst/var/www/html/test.php:17) in /home/virtual/site99/fst/var/www/html/test.php on line 39

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/virtual/site99/fst/var/www/html/test.php:17) in /home/virtual/site99/fst/var/www/html/test.php on line 39

Quite frankly ive got no idea why im getting an error since the headers are empty. Can anyone help?
 
J

Jonty

Guest
Hi Flamin_Squirrel

I'm afraid I don't really use sessions or cookies, so I'm not too au fait with the code involved in making it all work. From doing a little search, though, it seems that you may have already sent the headers on your test page, which causes an error when you then attempt to send more headers in your function.

This little post on PHPBuilder summarises this point . . .

... be sure you don't output *anything* before the session_start() or session_register() call. They imply sending a cookie header to the browser, and having something already sent means the headers cannot be sent anymore
So in short, it seems you should doublecheck that no headers are being sent before session_start(), which may be as simple as moving the relevant code to the top of your test page. This FAQTs page reitterates this point . . .

Warning: Cannot send session cookie - headers already sent
setcookie() defines a cookie to be sent along with the rest of the
header information. Cookies must be sent before any other headers are
sent (this is a restriction of cookies, not PHP). This requires you to
place calls to this function before any <html> or <head> tags.
I don't know whether this helps or not, but good luck nonetheless, and please feel free to post again if you're still having trouble.

Kind Regards
 
F

Flamin_Squirrel

Guest
It was being placed within <html> tags that was the problem. Thanks again for your help.
 
W

wyrd_fish

Guest
you can sometime get a simmilar problem with GD stuff, make sure they are at the top of the code, if thus don't help check to see if cookies are enabld on you computer... my bet is that you have put it too far down

PS. it won't need to be the very first thing just before any output to the browser ie. print() functions and HTML stuff
 
W

wyrd_fish

Guest
so.... you won't be needing my help after all...
 

Users who are viewing this thread

Top Bottom