dennismonsewicz Posted February 2, 2009 Share Posted February 2, 2009 I have this code: session_start(); ob_start(); $username = $_SESSION['username']; if(!$username) { header("location: index.php?action=login"); } the $username var is for testing... in Firefox i am getting a redirect loop error... any ideas? Quote Link to comment Share on other sites More sharing options...
rhodesa Posted February 2, 2009 Share Posted February 2, 2009 is the code you posted the code for index.php? the way it is written, you will get an infinite loop Quote Link to comment Share on other sites More sharing options...
flyhoney Posted February 2, 2009 Share Posted February 2, 2009 session_start(); ob_start(); if ($_GET['action'] != 'login') { $username = $_SESSION['username']; if(!$username) { header("location: index.php?action=login"); } } Quote Link to comment Share on other sites More sharing options...
dennismonsewicz Posted February 2, 2009 Author Share Posted February 2, 2009 thanks flyhoney! rhodesa: the code is at the top of my header.php... why would that have created an infinite loop? Quote Link to comment Share on other sites More sharing options...
rhodesa Posted February 2, 2009 Share Posted February 2, 2009 thanks flyhoney! rhodesa: the code is at the top of my header.php... why would that have created an infinite loop? do you include your header.php file on your index.php page? cus the page tries to load, runs header.php, doesn't find a username in SESSION, redirects to index.php?action=login, loads header.php, doesn't find a username in SESSION, redirects to index.php?action=login.... do you see the loop? Quote Link to comment Share on other sites More sharing options...
dennismonsewicz Posted February 2, 2009 Author Share Posted February 2, 2009 ah gotcha... yeah i see it.. thanks! 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.