Jump to content

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.