Re: session don't work with php that have version more than 4.03pl1
| From: | Chris Lee | Date: | Fri, 23 Mar 2001 13:39:07 +0000 |
| Subject: | Re: session don't work with php that have version more than 4.03pl1 | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-45294@lists.php.net to get a copy of this message | ||
you have to register the variable after it is set, not before. also only register the variable once,
dont keep re-registering it, some builds ie php-4.0.5 (snap) doesnt like re-registering vars
(sometimes).
<?php
include_once('time.egn');
if ( isset($PHPSESSID) )
session_id($PHPSESSID);
session_start();
if (!isset($HTTP_SESSION_VARS['SessionID']))
{
$SessionID = mtime();
session_register('SessionID');
}
$PHPSESSID = session_id();
$SID = "PHPSESSID=$PHPSESSID";
?>
this is my session file, works great for me.
--
Chris Lee
lee@mediawaveonline.com
""Weerapong Sirikanya"" <w_sirikanya@hotmail.com> wrote in message news:OE219GQvnbEG10Gai4o00003bd5@hotmail.com...
I have problem about using session with php that have version newer than 4.03pl1.
this is the test code.
-----------------
test_session.php
-----------------
<?php
session_start();
session_register("abc");
print "\$PHPSESSID -> $PHPSESSID<br>";
$abc = 1;
?>
<A HREF="test_session2.php">test_session2</A>
-------------------------------------------------------
result is:
$PHPSESSID -> 16529ad58656fc32ec826430b7b1e08b
test_session2
------------------
test_session2.php
------------------
<?php
print "\$PHPSESSID -> $PHPSESSID<br>";
print "\$abc -> $abc<br>";
?>
-------------------------------------------------------
result is:
$PHPSESSID -> 16529ad58656fc32ec826430b7b1e08b
$abc ->
this is the configuration:
Session Support enabled
Directive Local Value Master Value
--------- ----------- ------------
session.auto_start Off Off
session.cache_expire 80 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 no value no value
session.entropy_length 0 0
session.gc_maxlifetime 1440 1440
session.gc_probability 1 1
session.name PHPSESSID PHPSESSID
session.referer_check no value no value
session.save_handler files files
session.save_path /tmp /tmp
session.serialize_handler php php
session.use_cookies On On<br clear=all><hr>Get Your Private, Free
E-mail from MSN Hotmail at <a href="http://www.hotmail.com">http://www.hotmail.com</a>.<br></p>