Search code examples
phpazureazure-webjobswincache

Azure - "PHP Warning: session_start(): Cannot find save handler 'wincache'" after already being loaded


I've got a webjob running on my Azure app service that starts off with the session_start(); command.

At first - I was getting this error:

PHP Warning: session_start(): Cannot find save handler 'wincache' - session startup failed in D:\local\Temp\jobs\triggered\myCron\a4ypumbv.4i2\MyCron\myCron.php on line 3

What I ended up doing was going to my App Service -> Application Settings, and I set a custom setting of PHP_INI_SCAN_DIR set to D:\home\site, like so:

PHP_INI_SCAN_DIR set to home directory

Then, inside the D:\home\site directory, I uploaded a file titled phpconfig.ini, and inside I placed this:

extension=D:\home\site\ext\php_wincache.dll

I went to https://www.iis.net/downloads/microsoft/wincache-extension and downloaded the appropriate WinCache version - WinCache 1.3 for PHP 5.6 from SourceForge. After unpacking the .exe file, I copied the php_wincache.dll file into my D:\home\site\ext folder.

Now, when I run the webjob, I get this same error but also another error message right before it saying the wincache file was already loaded:

PHP Warning: Module 'wincache' already loaded in Unknown on line 0

PHP Warning: session_start(): Cannot find save handler 'wincache' - session startup failed in D:\local\Temp\jobs\triggered\myCron\a4ypumbv.4i2\MyCron\myCron.php on line 3

How can I make these warnings go away completely? Has anyone run into the same problem before?


Solution

  • wincache has been already installed and enabled in Azure App Service.

    In this case, you no longer need to call session_start() manually, Azure would start sessions on each page automatically.