Jump to content

session_start() issues...


141n

Recommended Posts

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

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

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

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.