0

Im having a problem with my code.
When I run it to php4 and it works fine. Then I tried it to php5. Im getting error -"Undefined Variable: _Session in ..."

<?php
	session_start();
	
	
	function logged_in() {
		
		return isset($_SESSION['idnum']);
		return isset($_SESSION['user_type']);
		return isset($_SESSION['fname']);
		
	}
	
	function confirm_logged_in() {
		if (!logged_in()) {
			redirect_to("index.php");
		}
	}
	function confirm_logged_in_admin() {
		if (!logged_in()) {
			redirect_to("admin.php");
		}
	}
	function booking_restriction(){
		if ($_SESSION['user_type'] == 4) {
			redirect_to("home.php");	
		}
	}	
	function confirm_if_admin() {
 		if ($_SESSION['user_type'] == 2 ||
			$_SESSION['user_type'] == 3 ||
			$_SESSION['user_type'] == 4 ) {
	         redirect_to("../home.php");}
	}	
?>
2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by rakwel10
0

Can you copy the full text from your error
And can you give us the source where you save the $_SESSIONS

0

Hi! thanks for the reply.

here is the error:

Notice: Undefined index: user_type in D:\xampp\htdocs\Main\includes\header.php on line 20

Notice: Undefined index: user_type in D:\xampp\htdocs\Main\includes\header.php on line 21

Notice: Undefined index: user_type in D:\xampp\htdocs\Main\includes\header.php on line 22

<?php 
if ($_SESSION['user_type'] == 1 ||
	$_SESSION['user_type'] == 2	||
	$_SESSION['user_type'] == 3) { 
$html2 = "<a href=\"booking/booktour.php\"><div>Book a Tour</div></a>";
echo $html2;
}else {}
?>

Edited by rakwel10: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.