duanguzhong5776 2015-11-16 12:21
浏览 58

会话变量user_id未更新

I used to do that to test if the user is logged in, and if so display his/her content:

if (login_check($conn) == true) {
  // show content here
}

But since it failed sometimes and I wanted to know why, I changed it to

$loginErro = login_error($conn);
if (!$loginErro) {
  // show content here
}

so I could get a number to know what the error was. But since then the errors increased. Many times the page says I'm not logged in, when in fact I'm logged in. I need to press F5 to refresh the correct session variable. The line that triggers the error in the login_error function is

if (!isset($_SESSION['user_id'])) {
    return 4;
}

Why my user_id is not being updated, mostly in the first time after a while (the session's cookie timeout, probably)?

EDIT: Somehow I could isolate the problem. When calling window.open() function, I was using

window.open('some_php_file.php','');

It opens multiple copies of the same php file, but loads them all ok. Then I changed it to

window.open('some_php_file.php','some_php_file.php');

to prevent opening multiple copies of the same window. Now, I open the first copy ok. When I click the button to open the window again, it is logging off from the system! Still trying to understand what's going on...

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
    • ¥15 正弦信号发生器串并联电路电阻无法保持同步怎么办
    • ¥15 划分vlan后,链路不通了?
    • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
    • ¥15 个人网站被恶意大量访问,怎么办
    • ¥15 Vue3 大型图片数据拖动排序
    • ¥15 Centos / PETGEM
    • ¥15 划分vlan后不通了
    • ¥20 用雷电模拟器安装百达屋apk一直闪退
    • ¥15 算能科技20240506咨询(拒绝大模型回答)