Roy766 Posted October 23, 2008 Share Posted October 23, 2008 Hi everybody! I'm somewhat new to sessions, so this question may seem really stupid to all of you PHP gods. Anyways, I'm trying to send a basic PHP variable between two pages through the use of sessions, and then I do some basic computations on the second page. The math I get on the second page is right, but I get these annoying error messages at the top of the page: First page: Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/www/roy766.freehostia.com/armygame.php:6) in /home/www/roy766.freehostia.com/armygame.php on line 8 Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/www/roy766.freehostia.com/armygame.php:6) in /home/www/roy766.freehostia.com/armygame.php on line 8 Second page: Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/www/roy766.freehostia.com/armygame2.php:6) in /home/www/roy766.freehostia.com/armygame2.php on line 7 Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/www/roy766.freehostia.com/armygame2.php:6) in /home/www/roy766.freehostia.com/armygame2.php on line 7 If someone could help it would be greatly appreciated! Thanks in advance! Side-note: session_register(); session_start(); $_SESSION['budget'] = $budget; session_start(); $budget = $_SESSION['budget']; Quote Link to comment Share on other sites More sharing options...
hellonoko Posted October 23, 2008 Share Posted October 23, 2008 Your session start has to come before anything at all in the page. so: <html> <?php session_start() will fail Quote Link to comment Share on other sites More sharing options...
Roy766 Posted October 23, 2008 Author Share Posted October 23, 2008 Putting it before an HTML Tag? Then it just comes out as plain text. Putting it after the PHP tag without a line break? That's what I did. Not putting code before it? Also what I did. ??? Please expand. I'm a bit slow with this. Quote Link to comment Share on other sites More sharing options...
hellonoko Posted October 23, 2008 Share Posted October 23, 2008 Just the session_start() function needs to be at the top of the page or the top of the first included page it has to be processed first. http://www.wallpaperama.com/forums/warning-session-start-function-session-start-cannot-send-session-t416.html <?php session_start(); ?> everything else Quote Link to comment 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.