PRodgers4284 Posted February 17, 2008 Share Posted February 17, 2008 I need a way of stoping a user on my website from accessing protected pages if they are not logged in, can anyone help? Im using the following code at the start of each page. <?php session_start(); include("database.php"); include("loginemployer.php"); ?> Quote Link to comment Share on other sites More sharing options...
PRodgers4284 Posted February 17, 2008 Author Share Posted February 17, 2008 Ive tried using the code below, but it doesnt work, not sure if im using the redirect header correctly, im putting the code on each protected page, can anyone provide some help or advice? if (!SESSION_username) { Header("Location: index2.php"); } Quote Link to comment Share on other sites More sharing options...
Chris92 Posted February 17, 2008 Share Posted February 17, 2008 <?php if( empty($_SESSION['username']) ) { header("location: index2.php"); } ?> Quote Link to comment Share on other sites More sharing options...
PRodgers4284 Posted February 17, 2008 Author Share Posted February 17, 2008 <?php if( empty($_SESSION['username']) ) { header("location: index2.php"); } ?> Thankyou very much, really appreciate your help 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.