vetman Posted October 7, 2008 Share Posted October 7, 2008 I'm having trouble with session's, I could use some help.I have this form listed below, it worked fine until I tried to use session in the code below that. I'm not sure if I'm doing it right, this is my first time with session. I would appreciate any help you cold provide. These are the error messages: Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/content/r/i/g/rigtway/html/login/login_success.php:3) in /home/content/r/i/g/rigtway/html/login/login_success.php on line 8 Warning: Cannot modify header information - headers already sent by (output started at /home/content/r/i/g/rigtway/html/login/login_success.php:3) in /home/content/r/i/g/rigtway/html/login/login_success.php on line 10 Login Successful Thanks in advance. <table width="300" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC"> <tr> <form name="form1" method="post" action="checklogin.php"> <td> <table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF"> <tr> <td colspan="3"><strong>Member Login </strong></td> </tr> <tr> <td width="78">Username</td> <td width="6">:</td> <td width="294"><input name="myusername" type="text" id="myusername"></td> </tr> <tr> <td>Password</td> <td>:</td> <td><input name="mypassword" type="text" id="mypassword"></td> </tr> <tr> <td> </td> <td> </td> <td><input type="submit" name="Submit" value="Login"></td> </tr> </table> </td> </form> </tr> </table> <?php // Check if session is not registered , redirect back to main page. // Put this code in first line of web page. session_start(); if(!session_is_registered(myusername)){ header("location:main_login.php"); } ?> <html> <body> Login Successful </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/127424-im-having-trouble-with-sessions-i-could-use-some-help/ Share on other sites More sharing options...
KevinM1 Posted October 7, 2008 Share Posted October 7, 2008 Sessions and general header() function calls must take place before any output is sent to the browser. EDIT: See the stickied thread we have on this already: http://www.phpfreaks.com/forums/index.php/topic,37442.0.html Quote Link to comment https://forums.phpfreaks.com/topic/127424-im-having-trouble-with-sessions-i-could-use-some-help/#findComment-659162 Share on other sites More sharing options...
PFMaBiSmAd Posted October 7, 2008 Share Posted October 7, 2008 Based on reading the error message you have three lines of something (new-lines, HTML...) before the <?php tag. Quote Link to comment https://forums.phpfreaks.com/topic/127424-im-having-trouble-with-sessions-i-could-use-some-help/#findComment-659206 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.