答案 0 :(得分:1)
我不想使用cookies
这极大地限制了你的可能性。现在,您无法绕过URL重写将会话标识符附加到URL。
答案 1 :(得分:0)
如果您想要一个基本的网站登录系统,请试试这个。
登录表单:
<form id="login-form" class="loginform" action='include/login.inc.php' method='POST'>
<input id="login-email" type='text' name='email' placeholder='Email'>
<input id="login-pwd" type='password' name='pwd' placeholder='Password'>
</form>
然后添加php代码。
Login.inc.php:
<?php
session_start();
include '../dbh.php';
$email = $_POST['email'];
$pwd = $_POST['pwd'];
$sql = "SELECT * FROM user WHERE email= ? ";
$stmt = mysqli_prepare($conn, $sql);
mysqli_stmt_bind_param($stmt, 's', $email);
mysqli_stmt_execute($stmt);
$result = mysqli_stmt_get_result($stmt);
$row = mysqli_fetch_assoc($result);
if(password_verify($pwd, $row['pwd'])) {
$_SESSION['id'] = $row['id'];
$userID = $row['id'];
header("Location: ../profile.php?id=$userID");
exit();
} else {
header("Location: ../login-error-page.php");
exit();
}
?>