User Tools

Site Tools


verify_user_is_logged_in_before_displaying_a_web_page

Verify user is logged in before displaying a web page (PHP)


// At the top of every page to ensure the user is logged in before showing them anything
 
session_start();
include('includes/preferences.php');
include('includes/functions.php');
 
getLogin();
 
///////////////////////////////////////////////////////////
// functions.php
////////////////////////////////////////////////////////
 
function getLogin($depth){
	if(!$_SESSION['logged_in']){ header('Location: http://'.$_SERVER['HTTP_HOST'].'/srv/login.php'); } 
}

Taken from here.

verify_user_is_logged_in_before_displaying_a_web_page.txt · Last modified: 2018/12/31 18:38 by 127.0.0.1