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

May 11, 2019 284 views
Apache PHP Ubuntu 16.04

Hello,

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 vardump the SESSION[‘userid’]. 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.

1 Answer

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

Have another answer? Share your knowledge.