View Complete Thread
  • Wincache 1.1.x file backed sessions not saving

    Oct 01, 2010 02:14 PM|sethmay|LINK

    I'm having this problem both in development and production. I recently moved to using Wincache as my session handler. It works very well, until the app pool resets and all the sessions are lost. It doesn't appear to be writing out session files and I can't seem to make it work in any of my environments. 

     session.save_path = "d:\inetpub\php_sessions"

    If I comment out session.save_handler = wincache in the ini file, and use the default, session files appear in the save_path. Uncomment save_handler (so wincache is the handler), and session files stop being created. It seems permissions on the save_path are fine, or files wouldn't be written by the default handler.

    Ok, gory detail time:

    Development environment:

    Windows 7 x64
    IIS 7
    PHP 5.3.3 nts VC9 x86 under fastcgi
    WinCache 1.1.630.0, 6/29/2010 10:57am (from file properties), phpinfo shows 1.1.0630.0, Jun 29 2010 10:57:43, not sure why the discrepancy

    Production environment:

    Windows Server 2008 R2 x64
    IIS 7.5
    PHP 5.3.3 nts VC9 x86 under fastcgi
    WinCache 1.1.630.0, 6/29/2010 10:57am (from file properties), phpinfo shows 1.1.0630.0, Jun 29 2010 10:57:43

    App pool is running under NETWORK SERVICE on both machines. Session directory has read/write permissions for NETWORK SERVICE, IUSR, IIS_IUSER (overly broad, I know).

    PHP.ini settings (identical on both machines)

    Directive Local Value
    session.auto_start Off
    session.bug_compat_42 Off
    session.bug_compat_warn Off
    session.cache_expire 180
    session.cache_limiter nocache
    session.cookie_domain no value
    session.cookie_httponly Off
    session.cookie_lifetime 0
    session.cookie_path /
    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.hash_bits_per_character 5
    session.hash_function 0
    session.name PHPSESSID
    session.referer_check no value
    session.save_handler wincache
    session.save_path d:\inetpub\php_sessions
    session.serialize_handler php
    session.use_cookies On
    session.use_only_cookies On
    session.use_trans_sid 0
    wincache.chkinterval 30
    wincache.debuglevel 0
    wincache.enablecli Off
    wincache.fcachesize 24
    wincache.fcenabled On
    wincache.fcenabledfilter no value
    wincache.fcndetect On
    wincache.filecount 4096
    wincache.ignorelist wincache.php
    wincache.localheap 0
    wincache.maxfilesize 256
    wincache.namesalt no value
    wincache.ocachesize 96
    wincache.ocenabled On
    wincache.ocenabledfilter no value
    wincache.scachesize 512
    wincache.ttlmax 1200
    wincache.ucachesize 512
    wincache.ucenabled On

    Simple script I use for testing:

    session_start();
    $i = 0;
    if (isset($_SESSION['myNum'])) $i = $_SESSION['myNum'];
    echo "session_save_path: " . session_save_path();
    echo "i: " . $i;
    ++$i;
    $_SESSION['myNum'] = $i;

    I run this repetitively, and see $i increment. I'll then recycle the app pool and watch it go to 0. Using the default session_handler, it works as expected across recycles.

    As recommended on other posts, I've used procmon to watch php_cgi.exe during the process. Using the default session_handler, I see explicit calls to the save_path. Using WinCache, there is nothing.

    No errors are reported by PHP, and the eventlogs are clear.

     

    Any ideas on what might be going on?

    Thanks

    Seth

    wincache PHP 5.3 backed session 1.1 file