doukuang1950 2015-12-06 21:02
浏览 190

如何修复Redirect Loop错误?

I am trying to make a user login site, I have a header.php and a home.php documents. I have the following code on the header.php page:

<?php 
include ("./inc/connect.inc.php"); 
session_start();
if (isset($_SESSION['user_login'])) {
}
else 
{
header("location: home.php");

}
?>

on the home.php page i have:

<?php
include("inc/header.inc.php");
?>
<?
if (!isset($_SESSION["user_login"])

?>

No matter what i try I am getting this loop error, please help :(

  • 写回答

2条回答 默认 最新

  • du59131 2015-12-06 21:14
    关注

    Always use exit(); after header("location: .."); or it might not work as expected.

    About Loop Error its possible both header.php and home.php are redirecting to each other.

    I am not sure if its the same file (correct me if am wrong)

    In header.php you are redirecting user to home.php if session is not set AND in home.php you are including a file header.inc.php(i am assuming its the same file) which is redirecting user to home.php again and again

    评论

报告相同问题?

悬赏问题

  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 用hfss做微带贴片阵列天线的时候分析设置有问题
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥120 计算机网络的新校区组网设计
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 海浪数据 南海地区海况数据,波浪数据