Warning: Unknown: Failed to write session data (files)

Warning: Unknown: Failed to write session data (files)

When the user updates php version in server many of them will get following error message like failed to write session data

Warning: Unknown: open(D:\Temp\php\session\sess_o3t1b1f1rovtpoilt5m39is7e4, O_RDWR) failed: No such file or directory (2) in Unknown on line 0

Warning: Unknown: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (D:\Temp\php\session\) in Unknown on line 0

The reason of this error is There is no Temp file created in your server.

This was a very familiar bug based on PHP versions. Based on your server environment, you want try setting the session folder permission to 777.

D:\Temp\php\session // This is my session folder path. It may vary based on server.

There is Two ways to fix this problem.

First Way

Second Way

I have fixed this problem by using below php code :

Add this code above of seesion_start();

I have create Temp\php\session folder in my cpanel root directory and set the permission to 777 which means the folder will be read and writable.

session_save_path :

The path where the temp session will store.

session.gc_probability : 

session.gc_probability in conjunction with session.gc_divisor is used to manage probability that the gc (garbage collection) routine is started. Defaults to 1.

Make sure the place where you are storing your sessions isn’t accessible to the world.

How to find Godaddy Cpanel path :

1. Login to Godaddy Hosting.

2. Goto your hosting details page by clicking hosting manage button.

3. Left side bar you can find Server Details

4. Under Server Details By clicking Show details you can see Absolute Hosting Path

5. Under Absolute Hosting Path you can find exact path of your cpanel on server. By clickng copy link you can copy the path.


This is worked for me. May this will help for some one.
Thanks for reading this article.
If you like this article don’t forget to share and comment.

Happy coding!.