This is REALLY weird (PHP Session problem)?

  • Thread starter Thread starter merlot7799
  • Start date Start date
M

merlot7799

Guest
I do website/database design for a company here in Las Vegas. I have several hundred web pages that the employees use after logging into the site. When they login, PHP creates a session variable called 'uid,' that I use to identify the user on each page. So, each page begins with a session_start, and I check for $_SESSION['uid'] first, and proceed if that variable passes a few tests. Right now, all of my pages start with:

<?php
session_start();
echo 'Session uid: '.$_SESSION['uid'];
...
?>

Here's my problem: When anyone in the office visits one particular page, $_SESSION['uid'] returns null, and the user is logged out (the entire session is killed). After visiting this page, they can't go anywhere in the site...they're logged out. It only happens on ONE of several hundred pages. And here's the catch: It only happens on ONE computer. Everyone in the office can visit every page, on every computer except one. On this one computer, everyone can visit every page except one. I have a mixture of XP/Vista boxes. The entire office is behind a router and the web server is at another location, so the web server only sees one IP address anyway.

I'm really stumped. Why just one computer? Why just one page on that computer? The first several lines of code on every page (the validation lines) are identical.

Any clue? Thanks!
just "JR," this is not true. Quoting the example from the php manual:

// page1.php

session_start();

echo 'Welcome to page #1';

$_SESSION['favcolor'] = 'green';
$_SESSION['animal'] = 'cat';
$_SESSION['time'] = time();

// Works if session cookie was accepted
echo '<br /><a href="page2.php">page 2</a>';

// Or maybe pass along the session id, if needed
echo '<br /><a href="page2.php?' . SID . '">page 2</a>';
?>

<?php
// page2.php

session_start();

echo 'Welcome to page #2<br />';

echo $_SESSION['favcolor']; // green
echo $_SESSION['animal']; // cat
echo date('Y m d H:i:s', $_SESSION['time']);

// You may want to use SID here, like we did in page1.php
echo '<br /><a href="page1.php">page 1</a>';
?>

Notice that session_start(); must appear as the first line of EVERY page for which you want to use session variables. The section of the manual that you're mentioning refers to more than one session_start() within the same page.
 
That's a good one... Are the sessions implemented with cookies? Maybe that particular machine has a problem with that - why only on the one page though... What if you just did a dump of your all your get/post/session vars to see if any of the other globals are doing something unexpected for that particular file? Good luck - sorry I couldn't think of anything more constructive to try..
 
Back
Top