141n Posted March 30, 2008 Share Posted March 30, 2008 Hey folks, OK, I hope I am doing something stupid here and it's easily solved, because I don't really know where I'm going wrong with this one: I'm using PHP5 and whenever I use session start(); - even if it is the only thing in the .php file - I get the following errors: Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /path/to/my/file/index.php:1) in /path/to/my/file/index.php on line 2 Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /path/to/my/file/index.php:1) in /path/to/my/file/index.php on line 2 As I say, I even tried just this: <?php session_start(); ?> And have the same problem, which I don't understand, because it is being called before anything else, particularly in the last case as it is the only thing being called. Am I doing something dumb with PHP5? I'm used to PHP4 and haven't done anything PHP orientated for about a while now. Thanks for taking the time to read this... Link to comment https://forums.phpfreaks.com/topic/98719-session_start-issues/ Share on other sites More sharing options...
ridiculous Posted March 30, 2008 Share Posted March 30, 2008 You need to put session_start() at the very top of the page, before you do absolutely anything else. Link to comment https://forums.phpfreaks.com/topic/98719-session_start-issues/#findComment-505177 Share on other sites More sharing options...
141n Posted March 30, 2008 Author Share Posted March 30, 2008 hey ridiculous - I have put session_start(); at the top of the page, there isn't anything that preceedes it which is what is confusing me. Even on a file that has only <?php session_start(); ?> I still get this error, where to my understanding it should just show a blank page, right? Link to comment https://forums.phpfreaks.com/topic/98719-session_start-issues/#findComment-505186 Share on other sites More sharing options...
ds111 Posted March 30, 2008 Share Posted March 30, 2008 correct, it should show a blank page. im not really sure on this one.. i did that on my server and i got a blank page...no errors. try clearing ur cookies, if ur in mozilla firefox, say "clear private data" it should clear SESSID which may be the cause of your problem. Link to comment https://forums.phpfreaks.com/topic/98719-session_start-issues/#findComment-505192 Share on other sites More sharing options...
141n Posted March 30, 2008 Author Share Posted March 30, 2008 nope, I cleared everything out of firefox's cache, relaunched but same thing =/ I wonder if it may be the actual server? It's (the site) hosted by godaddy.com anybody else had simillair issues with them regarding this sort of thing? Is it worth while sending them an email to see if it is something they can solve? Link to comment https://forums.phpfreaks.com/topic/98719-session_start-issues/#findComment-505206 Share on other sites More sharing options...
PFMaBiSmAd Posted March 30, 2008 Share Posted March 30, 2008 The error message - output started at ...index.php:1 (line 1) indicates that either there is some white-space (space, tab, newline...) before the <?php tag or the file is saved in UTF-8 encoding and the BOM (Byte Order Mark) characters at the start of the file are being output and are preventing the headers from being sent. Link to comment https://forums.phpfreaks.com/topic/98719-session_start-issues/#findComment-505211 Share on other sites More sharing options...
jack5100nv Posted March 30, 2008 Share Posted March 30, 2008 Check this http://us2.php.net/session Link to comment https://forums.phpfreaks.com/topic/98719-session_start-issues/#findComment-505216 Share on other sites More sharing options...
darkhappy Posted March 31, 2008 Share Posted March 31, 2008 i think you have to open the file in notepad and look for some text on the line before: <?php session_start(); ?> i think some editors like dreamweaver might put some data here that you can't see but that your browser will see and fail your script on. let me know if that is it. Link to comment https://forums.phpfreaks.com/topic/98719-session_start-issues/#findComment-505258 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.