User session expires immediately after opening new web page

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
tifoso
Forum Newbie
Posts: 1
Joined: Fri Sep 30, 2011 5:44 am

User session expires immediately after opening new web page

Post by tifoso »

Each of my web pages has the following:

Code: Select all

<?php
	require_once('auth.php');
?>
The auth.php looks like:

Code: Select all

<?php
	//Start session
	session_start();
	
	//Check whether the session variable SESS_MEMBER_ID is present or not
	if(!isset($_SESSION['SESS_MEMBER_ID']) || (trim($_SESSION['SESS_MEMBER_ID']) == '')) {
		header("location: access-denied.php");
		exit();
	}
?>

It does work as it should - access-denied message appears when the session expired after some longer time or when someone tries to access a password protected webpages without logging in. HOWEVER, I have added an .xml file to the server which now includes all the menu buttons like 'home', 'contact us' etc. After doing this, I've noticed that every time I open a web browser, especially IE and click one of the menu buttons after logging in, I get an instant message saying your session has expired etc. When I login again, it works fine until… until I close the web browser. After re-opening the web browser, logging in again and clicking on the menu buttons, the problem re-occurs.

Does anyone have an idea how this can be fixed?

Thank you!
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: User session expires immediately after opening new web p

Post by social_experiment »

If you print the $_SESSION variable, what values are displayed

Code: Select all

<?php
 print_r($_SESSION);
?>
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
Post Reply