dflow Posted May 31, 2011 Share Posted May 31, 2011 i have a login script im using if someone landed accidentally on a page i want him to be redirected and not have access <?php if (isset($session->logged_in)){ } else{header("Location: ../index.php");} ?> Link to comment https://forums.phpfreaks.com/topic/238014-session-redirect-problem/ Share on other sites More sharing options...
dougjohnson Posted May 31, 2011 Share Posted May 31, 2011 I would use the "full path" to the redirect page so you can use the code no matter what "level" the redirect happens in your site. header( 'Location: http://www.yoursite.com/new_page.html' ) ; Also, you might check for a specific value in your $session variable: if ($session == "Y") { Link to comment https://forums.phpfreaks.com/topic/238014-session-redirect-problem/#findComment-1223016 Share on other sites More sharing options...
dflow Posted May 31, 2011 Author Share Posted May 31, 2011 I would use the "full path" to the redirect page so you can use the code no matter what "level" the redirect happens in your site. header( 'Location: http://www.yoursite.com/new_page.html' ) ; Also, you might check for a specific value in your $session variable: if ($session == "Y") { thanks any other ideas? Link to comment https://forums.phpfreaks.com/topic/238014-session-redirect-problem/#findComment-1223226 Share on other sites More sharing options...
xyph Posted May 31, 2011 Share Posted May 31, 2011 You should always exit after calling header locations. This prevents the rest of your script from continuing to execute. Link to comment https://forums.phpfreaks.com/topic/238014-session-redirect-problem/#findComment-1223228 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.