html - How to check if the session is set in header.php -


i have more 30 pages , 20 of them has seen user check if user logged in using if statement.

if($_session['username']){ //display page (all html code here.) }else{  header("location: index.php"); } 

the question don't wanna type same thing every page. so, thought can type part in header.php

if($_session['username']){ 

and part in footer.php

}else{  header("location: index.php"); } 

but doesn't work that. wonder can do? efficient way?

in file:
if(!$_session['username']){ header("location: index.php"); }

and everywhere need it: require("myfile.php");


Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -