0

We are migrating a PHP website from an old host to a container. The old code runs on VM directly, now we built a container that facilitate the PHP website. Both old and new PHP website run on top of apache httpd with php version 5.4.16.

However, there's a feature of this website that saves user session under /var/lib/php/session that does not work in our new, containerized version. The directory seems to always be empty even if there are active sessions. We have checked the following:

  • The session configuration seems identical between the old and new site (pasting the config below)
  • We verified apache user is the owner of /var/lib/php/session directory
  • In php error logs, there doesn't seem to be anything indicating why the sessions are not saved

I am not familiar with PHP and don't know how I could debug this further, just checking if I can get some help on this.

  • Any chance we forgot to install any module that would allow session persistent?
  • Why would there not be any logs indicating the sessions not being saved? Do I need to somehow enable more logging to observe what is happening?
  • Was the session not saved or did it timeout and get wiped? Is there such setting somewhere that can cause this?

Our configuration

Session Support: enabled
Registered save handlers: files user
Registered serializer handlers: php php_binary

session.auto_start: Off
session.cache_expire: 180
session.cache_limiter: nocache
session.cookie_domainno value
session.cookie_httponly: Off
session.cookie_lifetime: 0
session.cookie_path: /
session.cookie_secure: Off
session.entropy_file: /dev/urandom
session.entropy_length: 32
session.gc_divisor: 1000
session.gc_maxlifetime: 1440
session.gc_probability: 1
session.hash_bits_per_character: 5
session.hash_function: 0
session.name: PHPSESSID
session.referer_check: no value
session.save_handler: files
session.save_path: /var/lib/php/session
session.serialize_handler: php
session.upload_progress.cleanup: On
session.upload_progress.enabled: On
session.upload_progress.freq: 1%
session.upload_progress.min_freq: 1
session.upload_progress.name: PHP_SESSION_UPLOAD_PROGRESS
session.upload_progress.prefix: upload_progress_
session.use_cookies: On
session.use_only_cookies: On
session.use_trans_sid: 0
user1763590
  • 117
  • 2
  • 14
  • You want to access the apaches `/var/lib/php/session`, right? But the PHP container has its own directory, so you need to mount it as a volume. https://stackoverflow.com/questions/23439126/how-to-mount-a-host-directory-in-a-docker-container – Markus Zeller Mar 20 '23 at 19:37
  • Thanks Markus. That is not what exactly what I meant though. The container has a directory named `/var/lib/php/session` but it is not writing to it. I don't need to mount it to the host VM. My problem is simply that the new application is not writing into that directory at all. It is empty even if there are active user connected to my website – user1763590 Mar 20 '23 at 22:31

1 Answers1

0

Turns out our script messed around the permission of /var/lib/php/session after having the container run as root it straighten things out

user1763590
  • 117
  • 2
  • 14