php - I am trying to verify the state of $_SESSION to allow access to a web page and it is not working -


On the page the following code will be the only redirect:

Here is the code that I'm trying to At the top of other pages, I want to check S_SESSION before allowing login permission:

    

My code for the login page here:


   0) {$ row = mysql_fetch_array ($ query, MYSQL_ASSOC); $ user = array ('Userid' = & gt; $ row ['userid'], 'email' = & gt; $ row ['email'], 'accesslevel' = & gt; $ row ['accesslevel'], 'password' = $ Session ['password']), 'enabled' = & gt; $ line ['enabled'],); // session session_start (); $ _SESSION ['login'] [] = $ User; top ('Location: message.php'); ob_end_clean (); exit ();} and {header ('location: login_redirect.php');}} and {print '& lt; p & gt; please make sure That you enter both an email address and password! 
Go back and try again. ';}} Else {print' & lt; form action = " login.php "method =" post "& gt; & Lt; P & gt; Email address: & lt; Input type = "article" name = "email" size = "20" /> gt; & Lt; / P & gt; & Lt; P & gt; Password: & lt; Input type = "password" name = "password" size = "20" /> gt; & Lt; / P & gt; & Lt; P & gt; & Lt; Input type = "submit" name = "submit" value = "login!" / & Gt; & Lt; / P & gt; & Lt; / Form & gt; '; } Include ('footer.html'); ? & Gt;

This is not working because the headers have already been sent when sent. You can always header.html

always place your redirect logic above any print statement.

Try entering the following code on each page.

  & lt ;? Php session_start (); If (! Isset ($ _ session ['login']) || (trim ($ _ session ['login']) == '')) {header ('location: login_redirect.php'); Go out(); } Include ('Connect_sloc_bb.php'); ('Header.html'); ? & Gt;    

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -