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"); ?> Link to comment https://forums.phpfreaks.com/topic/91518-login-session-help/ 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"); } Link to comment https://forums.phpfreaks.com/topic/91518-login-session-help/#findComment-468810 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"); } ?> Link to comment https://forums.phpfreaks.com/topic/91518-login-session-help/#findComment-468811 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 Link to comment https://forums.phpfreaks.com/topic/91518-login-session-help/#findComment-468822 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.