PHP sessions are not stored in set session.save_path directory - directory IS writable


I’m running PHP 7, apache on Ubuntu 16.04.

My issue is that my SESSIONs are set to null on page refresh after I deployed my site to DigitalOcean.

This problem does not occur on my local environment (XAMPP with Apache).

I have set a save_path which is also writable. I am checking if it is writable with

if (is_writable(session_save_path())) {
 echo "Yes";

and the above echo’s Yes on my site.

The directory permissions to the save_path directory are also set to 777.

To explain exactly what happens:

I login to my site (simple login written in php) which redirects me to the site admin page. There I var_dump the SESSION[‘user_id’]. So far so good. The user_id is shown on admin page. But, after that, if i try to reload the page/go to another page the SESSION is set to null and since I control access to the admin based on whether or not a session is set, the application(my site) redirects me back to the main index page. This does not happen on local environment - there everything works fine and code/scripts are the same.

When I check the save_path directory no files have been stored (on live server/digitalocean). I have tried other directories as well, such as /tmp.

My session.save_handler is set to files.

Does anyone know how to fix this issue? Or can guide me. I’m a bit lost.

Thanks in advance, Kubilay.


Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hey we went through the post. Our php development services can help you get the solution. Please contact us.