The code below works as expected on my ubuntu linux server 7.04
with LAMP installation.(o ut of the box)
The problem is on my Windows 2k3 Server. It seems
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('sessio n.save_path')
."/session_testing ";
if (!is_dir($sessd ir)) {
mkdir($sessdir, 07777);
}
ini_set('sessio n.save_path', $sessdir);
ini_set('sessio n.gc_probabilit y', 100);
ini_set('sessio n.gc_divisor', 100);
ini_set('sessio n.gc_maxlifetim e', 5);
session_start() ;
if(isset($_SESS ION['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>becaus e 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_st art Off Off
session.bug_com pat_42 Off Off
session.bug_com pat_warn On On
session.cache_e xpire 180 180
session.cache_l imiter 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_divi sor 1000 1000
session.gc_maxl ifetime 1440 1440
session.gc_prob ability 1 1
session.hash_bi ts_per_characte r 5 5
session.hash_fu nction 1 1
session.name PHPSESSID PHPSESSID
session.referer _check no value no value
session.save_ha ndler files files
session.save_pa th C:\PHP\sessiond ata C:\PHP\sessiond ata
session.seriali ze_handler php php
session.use_coo kies On On
session.use_onl y_cookies Off Off
session.use_tra ns_sid 0 0
with LAMP installation.(o ut of the box)
The problem is on my Windows 2k3 Server. It seems
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('sessio n.save_path')
."/session_testing ";
if (!is_dir($sessd ir)) {
mkdir($sessdir, 07777);
}
ini_set('sessio n.save_path', $sessdir);
ini_set('sessio n.gc_probabilit y', 100);
ini_set('sessio n.gc_divisor', 100);
ini_set('sessio n.gc_maxlifetim e', 5);
session_start() ;
if(isset($_SESS ION['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>becaus e 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_st art Off Off
session.bug_com pat_42 Off Off
session.bug_com pat_warn On On
session.cache_e xpire 180 180
session.cache_l imiter 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_divi sor 1000 1000
session.gc_maxl ifetime 1440 1440
session.gc_prob ability 1 1
session.hash_bi ts_per_characte r 5 5
session.hash_fu nction 1 1
session.name PHPSESSID PHPSESSID
session.referer _check no value no value
session.save_ha ndler files files
session.save_pa th C:\PHP\sessiond ata C:\PHP\sessiond ata
session.seriali ze_handler php php
session.use_coo kies On On
session.use_onl y_cookies Off Off
session.use_tra ns_sid 0 0
Comment