Session variables are not persisting between page loads

前端 未结 11 1412
梦谈多话
梦谈多话 2020-12-10 11:12

Can someone tell me why the session vars are not passing between pages? They were working up to 2 days ago. Now its not? There is a third party system that logs users in b

相关标签:
11条回答
  • 2020-12-10 11:19

    The answer to this is it was a hosting configuration error. Hosting company changed something and it has worked ever since.

    0 讨论(0)
  • 2020-12-10 11:19

    I had session.cookie_samesite = "Strict" in my runtime file and was trying to bounce my user from Oauth2.0 back to my site and the PHP session ID was getting erased when the redirects hit. I removed this from my runtime file and it works fine now.

    0 讨论(0)
  • 2020-12-10 11:20

    Make sure both pages are on the same domain. Even www.site.com is different than site.com

    0 讨论(0)
  • 2020-12-10 11:23

    In my case the solution was to have different parameter names in $_GET and $_SESSION.

    $_SESSION["businessid"] = $_GET["businessid"]; // Leads to problems with session. $_SESSION["business_id"] = $_GET["businessid"]; //Works perfectly.

    It sounds strange but that's my experience.

    0 讨论(0)
  • 2020-12-10 11:25

    Check the size of the session file: (code taken from this post)

    $sessionfile = ini_get('session.save_path') . '/' . 'sess_'.session_id();  
    echo 'session file: ', $sessionfile, ' ';  
    echo 'size: ', filesize($sessionfile), "\n";
    

    If your session file has zero size, make sure there is still disk space available on your server. That was the problem I had.

    Check disk space with df -h on a linux server.

    0 讨论(0)
  • 2020-12-10 11:25

    The only answer for this problem is to use session_start(); on the top of every page. It will work fine. Else you might need to contact your hosting provider about this problem.

    0 讨论(0)
提交回复
热议问题