mancombe Posted October 17, 2009 Share Posted October 17, 2009 ok so i have a site where people can register and login which works now thanks to someone on here that pointed out my error :-) Now my users click my links they can view the content without logging in, how do i stop that not sure if this is a simple issue or now many thanks Link to comment https://forums.phpfreaks.com/topic/178030-registration/ Share on other sites More sharing options...
waynew Posted October 17, 2009 Share Posted October 17, 2009 Firstly, only show "logged in" links to people who are logged in. I usually create a navigation bar for "logged out" users and a different navigation bar for people who are logged in. Like so: if($_SESSION['logged_in']){ require("logged_in_nav.php"); } else{ require("logged_out_nav.php"); } Secondly, you'll need to stop people who are not logged in from viewing pages that are only meant to be viewed by logged in users. Here's an example for that: if(!isset($_SESSION['logged_in'])){ header('Location: login.php'); //redirect back to login.php exit; //just to be sure that they still dont see the page if a redirect doesn't happen } Link to comment https://forums.phpfreaks.com/topic/178030-registration/#findComment-938712 Share on other sites More sharing options...
mancombe Posted October 17, 2009 Author Share Posted October 17, 2009 Firstly, only show "logged in" links to people who are logged in. I usually create a navigation bar for "logged out" users and a different navigation bar for people who are logged in. Like so: if($_SESSION['logged_in']){ require("logged_in_nav.php"); } else{ require("logged_out_nav.php"); } Secondly, you'll need to stop people who are not logged in from viewing pages that are only meant to be viewed by logged in users. Here's an example for that: if(!isset($_SESSION['logged_in'])){ header('Location: login.php'); //redirect back to login.php exit; //just to be sure that they still dont see the page if a redirect doesn't happen } That was a big help, thank you very much Link to comment https://forums.phpfreaks.com/topic/178030-registration/#findComment-938888 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.