Session ID expiring

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
okelly
Forum Commoner
Posts: 29
Joined: Thu Feb 23, 2006 2:18 pm

Session ID expiring

Post 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>');
?>
 
manixrock
Forum Commoner
Posts: 45
Joined: Sun Jul 20, 2008 6:38 pm

Re: Session ID expiring

Post 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();
okelly
Forum Commoner
Posts: 29
Joined: Thu Feb 23, 2006 2:18 pm

Re: Session ID expiring

Post 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
Post Reply