text: i need a simple php login code with session? warning: session_register(): cannot send session cookie - headers already sent by (output started at c:&#92;login.php:2) in c:&#92;login.php on line 20. above error occur when i use session. line 20 is [session_register("email");] sounds like you have your session_register() call too low in your code.  the script below checks a user name and password against a mysql query and refers the user to a new page on successful login, or prompts them to try again on a failed login.  note that you don't need to explicitly register a session variable; instantiating it registers it.   0 ) { $_session['loginid'] = $_post['user']; header( "location: newpage.php" ); else { $message = "login failed. please try again." } }    login page   login form   user name: <input type="text" id="user" name="user" size="30" value="" /> password: <input type="text" id="pass" name="pass" size="30" value="" />    