session problem
George Herson
gherson at snet.net
Wed Jun 19 05:44:15 EDT 2002
When i click an <a> link to move to another page on my site, a new session is
being created, and i don't know why. (I've had sessions working before, even in
this program that's now giving me problems.) On the page the click brings me to,
$PHPSESSID's value is predefined to the original session id, so PHP remembers
its value. But when i re-start the session, PHP creates a new session with a
new id, and any variables registered to the session are forgotten.
I've tried manually assigning this session id to the session, as shown below,
but still, as soon as I call session_start() a new session is created. What am
i doing wrong?
On the page I hyperlink to:
.
.
.
ob_start();
$zerothsessid=$PHPSESSID;
session_id( $PHPSESSID );
$firstsessid=session_id();
session_start(); // Starts a brand new session.
$secondsessid=session_id(); // This assigns a new value.
.
.
.
echo "zerothsessid=$zerothsessid<br/>\
";
echo "firstsessid=$firstsessid<br/>\
";
echo "secondsessid=$secondsessid<br/>\
";
ob_end_flush();
?>
In my output I'll have, for example:
zerothsessid=782e68bc3beabe79b50e3b1b0d32ba9c
firstsessid=782e68bc3beabe79b50e3b1b0d32ba9c
secondsessid=11dae9d39bc2b72a5783569472bd2532
From http://www.php.net/manual/en/function.session-id.php:
"string session_id ( [string id]) ...
If id is specified, it will replace the current session id. session_id() needs
to be called before session_start() for that purpose."
About one in 15 tries this will work, i.e., all of $zerothsessid, $firstsessid,
and $secondsessid are the same value.
My mod_php is 4.0.5.
thanks,
george
More information about the talk
mailing list