I have a problem that I cannot resolve.

All PHP sessions are stored in the directory /var/lib/php5/sessions/ and session files are stored there.

But completely randomly I see the following error: Failed to write session data (files). It happens 1 - 2 times per day that is it happens for 1-2 sessions per day. All the rest sessions are ok. And the files are also promptly.

To me it seems that sometimes PHP cannot write to the folder or (?) is it maybe the cause that file with the same name already exists.

What is the cause? How to prevent this?


You will need to gather more information to be able to make an informed decision.

  • Review your application/system logs and see if there is anything that can help you.
  • Increase the verbosity of your application/system logs so they provide more information.
  • Enable auditing and review the auditing logs

Correlate the event across whatever logs are involved and then once you know have the relevant information you will be able to solve the problem.

  • Lain, thanks for the answer. But it did not help. All logging is enabled (both on system level, web server level and php level) and this is the only error that shows up. The only suspicious thing is that in the session directory there are usually only a handful of files (that is correct because only current sessions are stored), but the size of the directory is huge... The error states that PHP could not write a file. I guess it could be something on directory level and not on application level. – mkurent Jul 29 '15 at 8:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.