Session Issue - Migration to Php5
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");}
}
?>
rakwel10
Junior Poster in Training
68 posts since Oct 2009
Reputation Points: 10
Solved Threads: 0
Can you copy the full text from your error
And can you give us the source where you save the $_SESSIONS
sv3tli0
Junior Poster in Training
78 posts since Aug 2011
Reputation Points: 10
Solved Threads: 18
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 {}
?>
rakwel10
Junior Poster in Training
68 posts since Oct 2009
Reputation Points: 10
Solved Threads: 0