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? Link to comment https://forums.phpfreaks.com/topic/143519-solved-redirect-loop-problem/ 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 Link to comment https://forums.phpfreaks.com/topic/143519-solved-redirect-loop-problem/#findComment-752881 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"); } } Link to comment https://forums.phpfreaks.com/topic/143519-solved-redirect-loop-problem/#findComment-752882 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? Link to comment https://forums.phpfreaks.com/topic/143519-solved-redirect-loop-problem/#findComment-752885 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? Link to comment https://forums.phpfreaks.com/topic/143519-solved-redirect-loop-problem/#findComment-752896 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! Link to comment https://forums.phpfreaks.com/topic/143519-solved-redirect-loop-problem/#findComment-752898 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.