Search code examples
phpfpmoraclelinux

Session Data Lost after Redirection in PHP-FPM


I have set up an Oracle Linux server with Apache httpd and PHP 8.3.12 (running as PHP-FPM). However, the $_SESSION["user"] variable returns null after a page redirection.

The PHP application was previously running successfully on an older CentOS server as well as using XAMPP under Windows desktop environments.

This problem causes my application not able to login users in.

Does anyone know how I can resolve this issue of losing session data after redirection when using PHP-FPM on Oracle Linux?

The session path is set to 0;777; in the /etc/php-fpm.d/www.conf file:

php_value[session.save_path] = "0;777;/var/lib/php/session"

Some things I have checked:

  • The session save path and permissions are correct
  • session.save_handler is set to "files"
  • Restarting PHP-FPM and httpd did not fix the problem.
  • I deleted all the files in the session.save_path, and upon logging into the application, new session files were generated in the session.save_path.

Any suggestions on how to troubleshoot this further would be appreciated.


Solution

  • The problem was finally resolved by installing the SSL certificate and accessing the website via HTTPS.