当用户登录时,从会话中检索数据的第一页就可以了。当我转到另一个页面时,会话是空白的。
我发现当用户登录并获取第一个用户页面 card.php 时,会话 ID 会发生变化。例如,在访问 subscription.php 时,无论出于何种原因,会话 ID 都不同。
我试图在下面列出有用的代码:
登录用户登录.php:
<?
session_start();
include('includingThis.php');
unset($_SESSION["emaillogin"]);
// Sørg for at e-mailen er undercased
$email = addslashes($_POST[email]);
$password = addslashes($_POST[pass]);
if ($email == "" || $password == "") {
header("Location: login.php?e=3");
exit;
die();
}
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
header("Location: login.php?e=4");
exit;
die();
}
$email = strtolower($email);
// TJEK OM BRUGEREN FINDES
if ($stmt = $con->prepare("SELECT email, pass, uid, profilepic, paid FROM stnd_users WHERE email=?")) {
/* bind parameters for markers */
$stmt->bind_param("s", $email);
$stmt->execute();
$stmt->bind_result($em, $pa, $u, $pp, $pai);
// Loop through each row in the result set
while ($stmt->fetch()) {
$gottenEmail = $em;
$gottenPass = $pa;
$uid = $u;
$profile_pic = $pp;
$paid = $pai;
}
$stmt->close();
}
if ($gottenEmail == "" || $gottenPass == "") {
header("Location: login.php?e=5");
exit;
die();
}
if (password_verify($password, $gottenPass)) {
// BRUGER LOGGES IND
// NÅR BRUGEREN FINDES, OG KODEN ER KORREKT
if ($uid != "") {
$_SESSION["user"] = $uid;
if ($paid == "true") {
// Bruger har betalt
if ($profile_pic == "true") {
header("Location: user/card.php");
exit;
} else {
header("Location: user/profilepic.php");
exit;
}
}
守着星空守着你