m118 Posted July 7, 2011 Share Posted July 7, 2011 I get an error message on the web page. Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at D:\AppServ\www\mission1\m.php:1) in D:\AppServ\www\mission1\m.php on line 1 I have put the session_start code on the top of the program, but it is not working. Please tell me how to fix it. Thank you very much. <?php session_start(); if(isset($_SESSION['myusername'])) { print "Your session username: ".$_SESSION['myusername']. "<br>"; print "Your session password: ".$_SESSION['mypassword']."<br>"; } else { print "Session does not exist"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/241336-session_start-problem/ Share on other sites More sharing options...
AyKay47 Posted July 7, 2011 Share Posted July 7, 2011 the error states that your output was started on line 1, so I am assuming that there is white space before your opening <?php tag Quote Link to comment https://forums.phpfreaks.com/topic/241336-session_start-problem/#findComment-1239640 Share on other sites More sharing options...
m118 Posted July 7, 2011 Author Share Posted July 7, 2011 This is the print screem of the program. I did not find the problem. [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/241336-session_start-problem/#findComment-1239642 Share on other sites More sharing options...
AyKay47 Posted July 7, 2011 Share Posted July 7, 2011 just to be sure I would write it like this <?php session_start(); if(isset($_SESSION['myusername'])) { print "Your session username: ".$_SESSION['myusername']. "<br>"; print "Your session password: ".$_SESSION['mypassword']."<br>"; } else { print "Session does not exist"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/241336-session_start-problem/#findComment-1239654 Share on other sites More sharing options...
Pikachu2000 Posted July 7, 2011 Share Posted July 7, 2011 If you have nothing at all (including spaces, tabs, empty lines, etc.) before the opening <?php tag, chances are you have a byte order mark in the file. Make sure your editor is set up to save files as UTF-8 without BOM. Quote Link to comment https://forums.phpfreaks.com/topic/241336-session_start-problem/#findComment-1239656 Share on other sites More sharing options...
AbraCadaver Posted July 7, 2011 Share Posted July 7, 2011 http://www.phpfreaks.com/forums/index.php?topic=37442.msg1385483#msg1385483 Quote Link to comment https://forums.phpfreaks.com/topic/241336-session_start-problem/#findComment-1239657 Share on other sites More sharing options...
AyKay47 Posted July 7, 2011 Share Posted July 7, 2011 If you have nothing at all (including spaces, tabs, empty lines, etc.) before the opening <?php tag, chances are you have a byte order mark in the file. Make sure your editor is set up to save files as UTF-8 without BOM. learned something new right there, thanks Pikachu Quote Link to comment https://forums.phpfreaks.com/topic/241336-session_start-problem/#findComment-1239660 Share on other sites More sharing options...
m118 Posted July 7, 2011 Author Share Posted July 7, 2011 how to set up to save files as UTF-8 without BOM ? I try to display chinese word. Quote Link to comment https://forums.phpfreaks.com/topic/241336-session_start-problem/#findComment-1239674 Share on other sites More sharing options...
AyKay47 Posted July 7, 2011 Share Posted July 7, 2011 it's normally located in the editors preferences, and is also sometimes called identification bytes Quote Link to comment https://forums.phpfreaks.com/topic/241336-session_start-problem/#findComment-1239686 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.