Search code examples
phpsessionsession-variables

php unseting $_SESSION variable on page referesh or redirected


I have moved our code to new server PHP version is 7.1 previously used were 5.6.

I am facing problems on $_SESSION variable. if page is redirected to other pages $_SESSION is have no values, even I reload this page again after commented session set as well $_SESSION values are gone.

ob_start(); session_start();
$_SESSION['abc'] = "manik";
echo "<pre>";
print_r($_SESSION);
echo "</pre>";
session_regenerate_id(true);
header('Location:test2.php');
exit();

session_save_path

Please advise.


Solution

  • you can check you session.save_path i THINK SO ITS NOT writable That's why ur facing this issue if (!is_writable(session_save_path())) { echo 'Session path "'.session_save_path().'" is not writable for PHP!'; }