Wincache 1.1.x file backed sessions not savingRSS

7 replies

Last post Oct 19, 2010 08:46 AM by eqkosch

  • 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

  • Re: Wincache 1.1.x file backed sessions not saving

    Oct 01, 2010 03:40 PM|ksingla|LINK

    Hi Seth.

    I recently found a bug which is probably what is causing this. I have fixed the bug for WinCache 1.2 release. There is a possible workaround which will require you to change your application pool name. Would you be willing to do that? If yes, send me your application pool name and I can tell you what you can change it to workaround this bug.

    Thanks,
    Kanwal

  • Re: Wincache 1.1.x file backed sessions not saving

    Oct 01, 2010 03:48 PM|laurin1|LINK

    Any chance this might fix my issue as well? :)

     

    http://forums.iis.net/p/1169879/1951548.aspx#1951548

  • Re: Wincache 1.1.x file backed sessions not saving

    Oct 01, 2010 05:04 PM|sethmay|LINK

    Kanwal, thanks for your help. My app pool name is:

    app.swis.org

     

    Thanks

    Seth

  • Re: Wincache 1.1.x file backed sessions not saving

    Oct 01, 2010 07:24 PM|ksingla|LINK

    Seth, If you change apppool name to app_swis_org, you won't run into the bug. Can you give it a try?

    Laurin1, doesn't seems like this bug would cause what you are seeing. I will need more info to debug your issue. I will follow up with you on the that forum thread.

  • Re: Wincache 1.1.x file backed sessions not saving

    Oct 04, 2010 11:25 AM|sethmay|LINK

    Success! Thank-you Kanwal for your prompt help. I made the setting change last night and it fixed the problem. Sessions are now creating files and are successfully surviving app-pool recycles and iis restarts.

     

    Just to recap, for anyone else who has the same or similar problems and stumble upon this thread:

    Problem: WinCache 1.1 (IIS 7x, PHP 5.3), set as the PHP session handler, was not writing out session files (file backed sessions). This meant that php sessions worked fine until the app-pool was recycled, then all sessions would be lost.

    Solution: My app-pools used the same name as my websites. My sites are the same as their domain name (i.e. www.somesite.com). This meant that my app-pool name had periods (.) in them. By changing the periods to underscores (_), the problem was mitigated. It is possible that there are other characters that cause problems as well, but the period was definitely the problem in my case. It sounds like this bug will be fixed in the v1.2 release of WinCache.

    Solution Recap: app-pool named 'www.somesite.com' was renamed 'www_somesite_com' and the problem was mitigated.

     

    Thanks
    Seth

    wincache PHP 5.3 backed session 1.1 file solved

  • Re: Wincache 1.1.x file backed sessions not saving

    Oct 04, 2010 12:01 PM|laurin1|LINK

    Nice catch guys.

  • Re: Wincache 1.1.x file backed sessions not saving

    Oct 19, 2010 08:46 AM|eqkosch|LINK

    Thanks for this I was having the same issue as I name the app pools the same way.