Jump to content

redirect for not logged it


dadamssg

Recommended Posts

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"); 
    }	 
?>

Link to comment
https://forums.phpfreaks.com/topic/142404-redirect-for-not-logged-it/
Share on other sites

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.

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.