Search code examples
phpwindowsiispermissionsfastcgi

Windows 2019 and PHP 7.3: "session_start(): ps_files_cleanup_dir: opendir failed: No such file or directory (2)"


Having this problem. I know there is similar questions, but none of them provided a solution.

  • Windows Server 2019 server core
  • PHP 7.3.7 x64 under IIS.

Error message:

PHP Fatal error: Uncaught ErrorException: session_start(): ps_files_cleanup_dir: opendir(D:\TempPHP) failed: No such file or directory (2).

  • The directory does exists and it is full of sessions files.
  • There is FULL permissions (I know, security risk, but I'm first trying to make it work) for the application pool user (IIS AppPool...), IUSR, IIS_IUSRS, LOCAL SERVICE, LOCAL NETWORK, SYSTEM and CREATE OWNER.
  • The error message seems to shows randomly.

Some relevant php.ini settings:

session.gc_probability = 1
error_log = "D:\TempPHP\PHP73x64_errors.log"
upload_tmp_dir = "D:\TempPHP\upload"
session.save_path = "D:\TempPHP"
sys_temp_dir = "D:\TempPHP"

edit: "D:\" is a local partition. Not a mapped or a shared drive. Logs and sessions are being written successfully. It seems that php just can't remove those files.


Solution

  • Ok, found out the problem.

    Seems like that with windows the session.save_path cannot be in a different disk / partition from the PHP executable path. In my case PHP directory was c:\Program Files\PHP\v7.3, so I moved the TempPHP folder from D: to C: partition and changed the value of session.save_path from "D:\TempPHP" to "C:\TempPHP". Now the sess_xxxxx files are automatically cleaned up and there is no more error messages.

    Don't know if this holds true for others php or windows versions.