I can't make session work, but cookie can, why?
| From: | TooooOld | Date: | Thu, 06 May 2004 08:28:56 +0000 |
| Subject: | I can't make session work, but cookie can, why? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-185503@lists.php.net to get a copy of this message | ||
I can't make session work if I set "session.use_trans_sid = 0", or I must
append SID to the URI to get session work.
And, the cookie works OK.
Here is my test code:
<?php
session_start();
if (!isset($_SESSION['test'])) { // First time you call it.
echo "<P>No session found - starting a session now.";
$_SESSION['test'] = "welcome back!";
} else { // Subsequent times you call it
echo "<P>Session found - ".$_SESSION['test'];
echo "<P>Sessions are working correctly</P>";
}
//not work
echo "<P><A HREF=session-test.php>Reload this page 1</A></P>";
echo "<P><A HREF=session-test.php?random=" . rand(1,10000) . ">Reload
this
page 2</A></P>";
echo "<P><A HREF=session-test.php?random=" . rand(1,10000) . SID .
">Reload
this page 3</A></P>";
//only this URL works OK.
echo "<P><A HREF=session-test.php?" . SID . ">Reload this page
4</A></P>";
?>
My system:
system: Windows 2000 Apache 1.3.29(and also tested under Apache 2.0.43)
PHP 4.3.5(SAPI)
php.ini settings:
Directive Value
--------------------------------------------
session.auto_start Off
session.bug_compat_42 Off
session.bug_compat_warn On
session.cache_expire 180
session.cache_limiter nocache
session.cookie_domain no value
session.cookie_lifetime 3600
session.cookie_path c:\cookie
session.cookie_secure Off
session.entropy_file no value
session.entropy_length 0
session.gc_divisor 1000
session.gc_maxlifetime 1440
session.gc_probability 1
session.name PHPSESSID PHPSESSID
session.referer_check no value
session.save_handler files
session.save_path c:\cookie
session.serialize_handler php
session.use_cookies On
session.use_only_cookies Off
session.use_trans_sid Off
Thanks for any advice.