0

We have a plugin that relies on $_SESSION variables. It is not working. We have set up a simple test to set the variable with set_session.php

<?php
session_start();
$_SESSION['test_variable'] = 'Testing Session Success!';
echo 'Session variable set.';
?>

Then get the variable get_session.php

<?php
session_start();
if (isset($_SESSION['test_variable'])) {
    echo 'Session variable value: ' . $_SESSION['test_variable'];
} else {
    echo 'Session variable not set.';
}
?>

The result is when calling the get_session.php is "session variable is not set". Hostinger has said they cannot help, we need to work it out. This function works on countless other hosting providers, and was working prior to our transition to hostinger. I have done vanilla WP installs, and still no luck.

Surely this is a setting/permission issue on their end? I am baffled they have washed their hands and said they cannot help. Our session support is enable, so I am unsure what else to do, other than migrate to a hosting provider that does work. enter image description here

Any insights would be amazing!

  1. Specifically debugging the non working plugin did plugin clash and theme tests.
  2. Installed plugin on new vanilla install on Hostinger - did not work
  3. Created test php functions to see if session variable is being set and retained on hostinger - did not work
  4. Installed plugin on another hosting provider website with same PHP and WP install - worked
  5. Used test php functions on another hosting provider website to see if sessions set and retained - worked
  • Check for "Headers already sent" warnings in the PHP error log. – Barmar Apr 06 '23 at 03:55
  • Please enable PHP error reporting and see whether you see something like `Warning: session_start(): Failed to read session data: user (path: /opt/xxxx/xxxx/xxxxxx)` – Ken Lee Apr 06 '23 at 04:13
  • Please also check the [this previously given answer on SO](https://stackoverflow.com/questions/19692157/session-variables-not-working-php) for troubleshooting the issue ... also check for the ```session_save_path()``` and permission... – Anant V Apr 06 '23 at 04:18

0 Answers0