After using suPHP on my Apache webserver and NGINX on another server, I realized that my cart systems are no longer working. Here are the symptoms I noticed.

  1. AJAX Carts does not display items
  2. When clicking checkout, the cart becomes empty
  3. After clicking update, the cart becomes empty

If you look at the symptoms, you’ll notice that every time you move to another page of your website, the cart is emptied. It only mean that the session data is not being saved. And with that, you’ll have to check your PHP save_path session settings in PHP.INI. Most often than not, the current value is /etc/php/sessions. You’ll have to check the folder permission. On my case, the folder is owned by root and the group is apache.

Since in suPHP, I use users other than apache and for nginx, I’m using user nginx, PHP cannot write into the folder. So a quick fix that I did was to add my users to apache group. Just like below.

usermod -a -G apache kwatog

That solved the problem but there’s a catch. Since the user (in the example, kwatog) has read+write access to the session folder, he can then read the session files that other users have in that same folder. For me, that’s not a problem because only me has access on my VPS. But for others, this could pose a problem. The solution proposed here is by overriding the save_patch settings via .htaccess. Here’s the code.

php_value session.save_path "tmp"

However, I haven’t tried it. Actually, I did but it failed and I don’t have time to investigate. Since the usergroup fix solves the initial problem, I’ll just get back to this at a later time.

By the way, if you don’t know where your PHP.INI is, it is most like in /etc/php.ini. However, in case you’ve installed it somewhere else, then you better read my How to Find PHP.INI Path

Comments are closed.

Post Navigation