普通网友 2016-01-23 04:31
浏览 11

会话变量在一段时间后丢失或在php中立即丢失

Whenever the user login on my page the username is stored as a $_SESSION variable like so:

$_SESSION['username'] = $username; 

where $username is the email address of the user and further user is assumed to be logged in. What I have observed is that my user is automatically logged out instantly after logging in or after few times. Are my session variables lost or what other problem should be?

My session_start() is always at the beginning and there is no space above it, so this is not the problem.

The part of my login code when login is successful is:

 if ($usererror != 1 && $passworderror != 1 && $conferror != 1) {

    $_SESSION["username"] = $username;
    $_SESSION["password"] = $password;

    header('Location:/dashboard_test/index.php');
}

The first page that accepts login has the first few lines as:

session_start();
$username = $_SESSION['username'];
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 在获取boss直聘的聊天的时候只能获取到前40条聊天数据
    • ¥20 关于URL获取的参数,无法执行二选一查询
    • ¥15 液位控制,当液位超过高限时常开触点59闭合,直到液位低于低限时,断开
    • ¥15 marlin编译错误,如何解决?
    • ¥15 有偿四位数,节约算法和扫描算法
    • ¥15 VUE项目怎么运行,系统打不开
    • ¥50 pointpillars等目标检测算法怎么融合注意力机制
    • ¥20 Vs code Mac系统 PHP Debug调试环境配置
    • ¥60 大一项目课,微信小程序
    • ¥15 求视频摘要youtube和ovp数据集