cowboysdude Posted July 26, 2008 Share Posted July 26, 2008 I put this in my index.php: session_start(); // If they don't visit index.php this variable won't be set. $_SESSION['has_session'] = true; to set the session... Then in a php file I didn't want to allow direct access without going through index.php I used this: session_start(); // Check if the variable has been set. if(!isset($_SESSION['has_session'])) { // It hasn't, they must go to index.php. header('Location: http://' . getenv('HTTP_HOST') . '/', true, 302); exit(); } However now I get this error: The browser has stopped trying to retrieve the requested item. The site is redirecting the request in a way that will never complete. Now I believe the first part is setting the session and the index.php should load no matter what... however it won't load now... Quote Link to comment https://forums.phpfreaks.com/topic/116719-solved-php-session-question/ Share on other sites More sharing options...
DeanWhitehouse Posted July 26, 2008 Share Posted July 26, 2008 that means that the page is being redirected constantl Quote Link to comment https://forums.phpfreaks.com/topic/116719-solved-php-session-question/#findComment-600162 Share on other sites More sharing options...
.josh Posted July 26, 2008 Share Posted July 26, 2008 I'm just curious: if you don't want the user to access that page without going through index.php first, why not just make your header location index.php? Quote Link to comment https://forums.phpfreaks.com/topic/116719-solved-php-session-question/#findComment-600182 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.