jdock1 Posted April 23, 2009 Share Posted April 23, 2009 I coded a simple three part register/login script, the register page, the login page, and the member page. I coded this with a PHP pocket reference book. So now, I face the problem of making php pages login protected. I added this code to the pages that I want to be login protected: <?php session_start(); if ( @$_SESSION['cookie'] != "yes" ) { header("Location: login.php"); exit (); } ?> The redirect works to login.php, but when I login and go to that page (for example, test.php), it redirects me to the member page. What am I doing wrong?? Thanks in advance! Link to comment https://forums.phpfreaks.com/topic/155426-problem-with-simple-login-script-i-coded/ Share on other sites More sharing options...
mikesta707 Posted April 23, 2009 Share Posted April 23, 2009 well it wouldnt redirect you to the members page unless there was a command to do so. Is there a redirect somewhere in that script that you havent included? Link to comment https://forums.phpfreaks.com/topic/155426-problem-with-simple-login-script-i-coded/#findComment-817868 Share on other sites More sharing options...
premiso Posted April 23, 2009 Share Posted April 23, 2009 Avoid using the @. Instead I would use this: <?php session_start(); if (!isset($_SESSION['cookie']) || $_SESSION['cookie'] != "yes" ) { header("Location: login.php"); exit (); } ?> As far as why it is redirecting to the member page, you need to post the full code for that page. As I do not see anywhere there that would redirect you to the members page. Link to comment https://forums.phpfreaks.com/topic/155426-problem-with-simple-login-script-i-coded/#findComment-817872 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.