Someone please try this simple experiment and enlighten me as to what PHP is considering a "session". I have register_globals turned on...or off, doesn't make any difference to this.
=========test1.html========
<?
if ($uname) {
session_register("mem");
$HTTP_SESSION_VARS["mem"]=$uname;
}
echo session_name().'<br>';
echo session_is_registered("mem").'<br>';
echo $HTTP_SESSION_VARS["mem"].'<br>';
?>
<form>
<input name="uname">
</form>
<a href="test2.html">Next</a>
==========test2.html========
<?
echo session_name().'<br>';
echo session_is_registered("mem").'<br>';
echo $HTTP_SESSION_VARS["mem"].'<br>';
?>
<a href="test1.html">Previous</a>
============================
For me, the results are:
Test1: works fine, reporting the session_name, that "mem" is registered with the session, and correctly echoing that var.
Test2: oops...reports only the (same) session name...no "session" variable.
Please note that there isn't really anything in between the two pages that would cause the session to dump its variables...or am I missing something?
I've tried HTTP_STATE_VARS, gc_globals, turning register_globals on and off, GLOBALS...ad infinitum.
I can ONLY keep the variables alive by propagating them in the URL, which I would rather not do, because many visitors send the URL they see to their friends, which is a big security risk when the URL string includes login information.
I reallyreally appreciate any modifications to the above code or my server settings that will allow me to use sessions.
Thanks a lot in advance!
Using: FreeBSD 4.4, PHP 4.1.2
PHP Config: './configure' '--enable-inline-optimization' '--with-apxs=/usr/local/apache/1.3.12/bin/apxs' '--with-config-file-path=/usr/local/lib' '--disable-debug' '--enable-memory-limit' '--with-gettext' '--without-pear' '--with-regex=system' '--enable-mbstring' '--enable-mbstr-enc-trans' '--with-iconv=/usr/local' '--with-gdbm=/usr/local' '--with-dbm=/usr/local' '--enable-sockets' '--enable-versioning' '--enable-ftp' '--with-imap' '--with-mcrypt=/usr/local' '--with-mhash=/usr/local' '--with-mysql=/usr/local/mysql' '--with-zlib' '--with-zlib-dir=/usr'
PHP.ini: session_autostart = 1
(track_vars is always on as of v.4.0.3)