Jump to content

sending people back to login page if session isn't started


webguync

Recommended Posts

I need to check to see if people have logged in before entering a page and if not, send them back to login.

 

I  know it's something like:

 

<?php
session_start();
if(($_SESSION['username'] == 1)  && isset($_SESSION['password'])) {
?>

 

how do I send them to a page login.php etc?

well you say on your login page yo put three username in $_SESSION['username'] you check like this

<?php
session_start();
if(!isset($_SESSION['username'])){
    header("Location: login.php");
    exit;
}
//rest of page
?>

 

Scott.

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.