Page 1 of 1

Session ID expiring

Posted: Thu Jul 24, 2008 6:00 am
by okelly
hello all

my modest php application is working fine (Vista home, Apache 2.2.9, php5.2.6, MySQL5) with the exception after logging-in successfully to my php application I try and click another .php page within my application I get the error "you need to be logged in to use this feature. please login here[link]"

The code that is triggering the error is listed below. Presumably I have overlooked a "session ID" or "cookie" setting somewhere in my Apache 2.2.9 setup or my php5.2.6 settings.
The "login.php" referred to below has standard username and pw capture and post settings..nothing untoward that I can see..

Any ideas anyone? Thanks very much..
Conor

Code: Select all

 
<?php
if (!isset($_SESSION['user']))
die('you need to be logged in to use this feature.<br />please login <a href="login.php">here</a>');
?>
 

Re: Session ID expiring

Posted: Thu Jul 24, 2008 7:11 am
by manixrock
You need to initialize the session at the top of every php page (so you can access the contents of the $_SESSION variable):

Code: Select all

session_start();

Re: Session ID expiring

Posted: Thu Jul 24, 2008 7:26 am
by okelly
each of the pages has an include("connect.php"); and there's a session_start(); statement in the connect.php. It's working fine on my production server (hosted with an ISP) so i guess the probelm is with my own Apance or local php settings...

rgds
Conor