我的 php SESSION 变量有问题我的身份验证系统在我的 xampp 服务器上运行良好,现在我有问题,因为我搬到了 bluehost
通常,如果我打开像 index.php 这样的页面,它会检查您是否已登录,如果您没有将您发送到登录页面,但这不起作用,只是为了测试,我尝试回显$_SESSION['username']
并出现空白的
现在我按照 ALEX 所说的做了,但出现了这个错误:无法修改标头信息 - 标头已由 /home7/blogboua/public_html/blog 中的(输出开始于 /home7/.../public_html/blog.php:4)发送。第 22 行的 php
这是代码:
<?php session_start(); ?>
<html>
<head>
<?php
ini_set('display_errors', 'on');
error_reporting(E_ALL);
/*-----Connect to Database-----*/
include ('connect_database_2.php');
//check if logged in
function isLoggedIn()
{
if(isset($_SESSION['valid']) && $_SESSION['valid'])
return true;
return false;
}
//if the user has not logged in
if(!isLoggedIn())
{
header('Location: login_form.html');
die();
}
/* get username */
$username = $_SESSION['username'];
/*-----Include Navigation------*/
include ('frame.html');
?>