PDA

View Full Version : php session errors..



darkywarkey
05-09-2008, 12:55 AM
Implementing session control on a site, but I keep getting this error at the line the session_start() function is called. Any ideas as to why this is?


Cannot send session cookie - headers already sent by (output started at /home/strateas/public_html/index.php:12) in /home/strateas/public_html/index.php on line 30
________
no2 vaporizer (http://no2vaporizers.com)
________
Yamaha fzr400 specifications (http://www.yamaha-tech.com/wiki/Yamaha_FZR400)

linFox
05-09-2008, 02:39 AM
The session_start() call need to come before any output is made (either intentional output or errors) in order to set the cookie. The error indicates the session_start() is on line 30, and the output came from line 12.

darkywarkey
05-10-2008, 04:22 PM
Ok, so I tried moving the session_start() up to the beginning of the page to avoid the output error - now I get a session cache limiter error, similar to the previous error.



Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/strateas/public_html/index.php:3) in /home/strateas/public_html/index.php on line 4

line 3 is just the <?php tag.

:confused: :confused:
________
Cheyenne (http://www.chevy-wiki.com/wiki/Chevrolet_Cheyenne)
________
LAMBORGHINI 400GT MONZA SPECIFICATIONS (http://www.lamborghini-tech.com/wiki/Lamborghini_400GT_Monza)

linFox
05-11-2008, 06:29 PM
Anything outside the PHP tags (even blank lines, etc) is sent directly to the page, this means the headers have already been sent by the time you're opening the PHP block. You have to move or remove everything on the first two lines, so the opening PHP tag is the very first thing in the file.

darkywarkey
05-11-2008, 09:31 PM
I tried that too. I put this in line 1...
<?php session_start(); ?>

and got the same errors but they now refer to line 1 for the output and session_start() function. Is there any other possible causes for these errors?
________
MH02 (http://www.honda-wiki.org/wiki/Honda_MH02)
________
Lovely Wendie (http://www.lovelywendie99.com/)

r2b2
05-11-2008, 11:16 PM
This is mentioned in the comments on the session_start PHP Manual page:


It was then that I thought to check the encoding of my php file. Turns out I had left my editor in UTF-8 encode mode from some previous (i18n) work I had done. I switched to ANSI and that fixed the problem. Suddenly the same file that had caused php to scream in pain was being processed without any issues.

I also noted that I could set the editor to "Encode in UTF-8 without BOM" and that also works. The BOM is the byte order mark which php probably glosses over (or does not understand). I didn't look too far into it.

Sounds a bit of a long shot but maybe worth considering...

darkywarkey
05-11-2008, 11:41 PM
Yep! That was it. I never would have thought to check that... thanks!
________
Honda RA300 history (http://www.honda-wiki.org/wiki/Honda_RA300)
________
Curvy live (http://www.girlcamfriend.com/webcam/curvy/)

Hot DesignZ
05-22-2008, 03:30 PM
I have read your article and have one question to ask, would you pls Post your MSN to me?


Can we get a ban on this clown?