我已经测试了我的网站,它有一个用 php 编写的登录系统,它在本地服务器上运行良好(我使用 xampp)。我已将文件上传到网络服务器。假设我已经提供了凭据,然后我正在登录。它应该做的是创建会话并将我重定向到另一个名为 home.php 的页面。这在本地服务器中运行良好,但在 Web 服务器中运行良好。它不会按预期创建会话。
这是 login.php 中的代码:
<?php
require 'core/init.php';
$general->logged_in_protect();
if (empty($_POST) === false) {
$username = trim($_POST['username']);
$password = trim($_POST['password']);
if (empty($username) === true || empty($password) === true) {
$errors[] = 'Sorry, but we need your username and password.';
} else if ($users->user_exists($username) === false) {
$errors[] = 'Sorry that username doesn\'t exists.';
} else if ($users->email_confirmed($username) === false) {
$errors[] = 'Sorry, but you need to activate your account.
Please check your email.';
} else {
if (strlen($password) > 18) {
$errors[] = 'The password should be less than 18 characters, without spacing.';
}
$login = $users->login($username, $password);
if ($login === false) {
$errors[] = 'Sorry, that username/password is invalid';
}else {
session_regenerate_id(true);// destroying the old session id and creating a new one
$_SESSION['id'] = $login;
header('Location: home.php');
exit();
}
}
}
?>
问题出在哪里?请指教,
提前致谢!