NYCPHP Meetup

NYPHP.org

session problem

George Herson gherson at snet.net
Wed Jun 19 07:22:07 EDT 2002


The last attempt obviously got cut off (where i had three dots, one per line) so 
resending...

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.  Its configure command, according to phpinfo():
'./configure' '--with-pgsql=/var/lib/pgsql' '--with-apxs'

Other settings:

session.use_trans_sid
1 1

Session Support enabled

Directive Local Value Master Value
session.auto_start
Off Off
session.cache_expire
180 180
session.cache_limiter
nocache nocache
session.cookie_domain
no value no value
session.cookie_lifetime
0 0
session.cookie_path
/ /
session.cookie_secure
Off Off
session.entropy_file
/dev/urandom /dev/urandom
session.entropy_length
16 16
session.gc_maxlifetime
600 600
session.gc_probability
20 20
session.name
PHPSESSID PHPSESSID
session.referer_check
1 1
session.save_handler
files files
session.save_path
/tmp /tmp
session.serialize_handler
php php
session.use_cookies
On On


thanks,
george





More information about the talk mailing list