dadamssg Posted January 25, 2009 Share Posted January 25, 2009 Im trying to make one of my pages redirect to the login page if the $_session['logname'] isn't set. but its not doin anything...still displays the page. heres my isset code that should redirect but won't <?php /*File: testdisplay.inc *Display test form */ session_start(); include("sdateselectfun.php"); include("edateselectfun.php"); include("timeselectfuncs.php"); if (! isset($_SESSION['logname'])) { header("Location: /Members/Login2.php"); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/142404-redirect-for-not-logged-it/ Share on other sites More sharing options...
gevans Posted January 25, 2009 Share Posted January 25, 2009 var_dump($_SESSION); put that on the page and see if it is actually set Quote Link to comment https://forums.phpfreaks.com/topic/142404-redirect-for-not-logged-it/#findComment-746110 Share on other sites More sharing options...
dadamssg Posted January 26, 2009 Author Share Posted January 26, 2009 what exactly does var_dump() do? Quote Link to comment https://forums.phpfreaks.com/topic/142404-redirect-for-not-logged-it/#findComment-746130 Share on other sites More sharing options...
dadamssg Posted January 26, 2009 Author Share Posted January 26, 2009 anyone? Quote Link to comment https://forums.phpfreaks.com/topic/142404-redirect-for-not-logged-it/#findComment-746150 Share on other sites More sharing options...
Cosizzle Posted January 26, 2009 Share Posted January 26, 2009 http://ca3.php.net/manual/en/function.var-dump.php Im not sure why its not redirecting, you might want to try an ob_start() too Quote Link to comment https://forums.phpfreaks.com/topic/142404-redirect-for-not-logged-it/#findComment-746151 Share on other sites More sharing options...
GingerRobot Posted January 26, 2009 Share Posted January 26, 2009 var_dump does exactly what it says it does in the manual. You need to learn to look things like that up yourself - it's not even difficult, just type the function name after www.php.net/ (e.g. www.php.net/var_dump) and the manual really is a great resource. Also, you need to make sure you exit after that header() - you don't want the rest of the script executing. Quote Link to comment https://forums.phpfreaks.com/topic/142404-redirect-for-not-logged-it/#findComment-746152 Share on other sites More sharing options...
.josh Posted January 26, 2009 Share Posted January 26, 2009 also your header call is not going to work if you have output before it. You have 3 files included in before it that may or may not have output. Quote Link to comment https://forums.phpfreaks.com/topic/142404-redirect-for-not-logged-it/#findComment-746153 Share on other sites More sharing options...
dadamssg Posted January 26, 2009 Author Share Posted January 26, 2009 hmmm...ok i think it will work now, but how do i close session when the user X's out of the site? i can begin a session with a username x out of the window, get back on and i still have my session open...? Quote Link to comment https://forums.phpfreaks.com/topic/142404-redirect-for-not-logged-it/#findComment-746165 Share on other sites More sharing options...
premiso Posted January 26, 2009 Share Posted January 26, 2009 hmmm...ok i think it will work now, but how do i close session when the user X's out of the site? i can begin a session with a username x out of the window, get back on and i still have my session open...? Session ends when the browser is closed. You can have a timeout set if you are using a db, if no activity in 20 minutes, set the user as logged out. Quote Link to comment https://forums.phpfreaks.com/topic/142404-redirect-for-not-logged-it/#findComment-746168 Share on other sites More sharing options...
dadamssg Posted January 26, 2009 Author Share Posted January 26, 2009 ive never heard of that way, where can i find more info about timing users out? Quote Link to comment https://forums.phpfreaks.com/topic/142404-redirect-for-not-logged-it/#findComment-746169 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.