|
Posted by deciacco on 09/04/07 02:22
Below is a little piece of code.
This code works as expected on my ubuntu linux server 7.04
with LAMP installation.(out of the box)
The problem is on my Windows 2k3 Server. It appears as though
the garbage collector never deletes the session file, or deletes
it and recreates it immediately, so the script never gets to
the "setting session variable" after the first time.
I'm using php 5.2.4 isapi.
("\\" is used in $sessdir for windows. only difference.)
I've searched google, and read the sessions pages on php.net.
Any ideas? Something I might have missed?
Thanks!
*************
<?php
$sessdir = ini_get('session.save_path')
."/session_testing";
if (!is_dir($sessdir)) {
mkdir($sessdir, 07777);
}
ini_set('session.save_path', $sessdir);
ini_set('session.gc_probability', 100);
ini_set('session.gc_divisor', 100);
ini_set('session.gc_maxlifetime', 5);
session_start();
if(isset($_SESSION['isalive']))
{
echo "now wait for 5 seconds and refresh twice";
echo "<br>on the second refresh ";
echo "the session will be set again";
echo "<br>because the session data file would";
echo " have been deleted by the gc";
}else{
echo "setting session variable....";
$_SESSION['isalive'] = true;
echo "<br>set!...now refresh...";
}
?>
**************
session settings in ini:
---------------------------
Session Support enabled
Registered save handlers files user memcache sqlite
Registered serializer handlers php php_binary wddx
Directive Local Value Master Value
session.auto_start Off Off
session.bug_compat_42 Off Off
session.bug_compat_warn On On
session.cache_expire 180 180
session.cache_limiter nocache nocache
session.cookie_domain no value no value
session.cookie_httponly Off Off
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_divisor 1000 1000
session.gc_maxlifetime 1440 1440
session.gc_probability 1 1
session.hash_bits_per_character 5 5
session.hash_function 1 1
session.name PHPSESSID PHPSESSID
session.referer_check no value no value
session.save_handler files files
session.save_path C:\PHP\sessiondata C:\PHP\sessiondata
session.serialize_handler php php
session.use_cookies On On
session.use_only_cookies Off Off
session.use_trans_sid 0 0
Navigation:
[Reply to this message]
|