Partner and Community Forums
Windows Cache Extension for PHP
Wincache 1.1.x file backed sessions not saving
Last post Oct 19, 2010 01:46 PM by eqkosch
Oct 01, 2010 07: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:
Windows 7 x64
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
Windows Server 2008 R2 x64
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)
Simple script I use for testing:
$i = 0;
if (isset($_SESSION['myNum'])) $i = $_SESSION['myNum'];
echo "session_save_path: " . session_save_path();
echo "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?
Oct 01, 2010 08:40 PM|ksingla|LINK
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.
Oct 01, 2010 08:48 PM|laurin1|LINK
Any chance this might fix my issue as well? :)
Oct 01, 2010 10:04 PM|sethmay|LINK
Kanwal, thanks for your help. My app pool name is:
Oct 02, 2010 12:24 AM|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.
Oct 04, 2010 04:25 PM|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.
Oct 04, 2010 05:01 PM|laurin1|LINK
Nice catch guys.
Oct 19, 2010 01:46 PM|eqkosch|LINK
Thanks for this I was having the same issue as I name the app pools the same way.