gtrufitt Posted March 11, 2008 Share Posted March 11, 2008 How is this done please? Cheers Quote Link to comment https://forums.phpfreaks.com/topic/95671-redirecting-to-login-page-if-session-variable-is-not-set/ Share on other sites More sharing options...
pocobueno1388 Posted March 11, 2008 Share Posted March 11, 2008 <?php session_start(); if (!isset($_SESSION['sess_name'])){ header("Location: login.php"); } Quote Link to comment https://forums.phpfreaks.com/topic/95671-redirecting-to-login-page-if-session-variable-is-not-set/#findComment-489808 Share on other sites More sharing options...
laffin Posted March 11, 2008 Share Posted March 11, 2008 ya forgot an exit after header, otherwise code will continue to run Quote Link to comment https://forums.phpfreaks.com/topic/95671-redirecting-to-login-page-if-session-variable-is-not-set/#findComment-489815 Share on other sites More sharing options...
discomatt Posted March 11, 2008 Share Posted March 11, 2008 exit after header is not completely necessary, but recommended. A proper browser (every one i've ever used) will parse the header before rendering the page. If the page has data that you REALLY don't want the user to see, then exit just to be safe. Quote Link to comment https://forums.phpfreaks.com/topic/95671-redirecting-to-login-page-if-session-variable-is-not-set/#findComment-489868 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.