会话缓存限制器

时间:2014-02-03 19:07:56

标签: php session warnings

是的我知道这已经完成了,但这个问题不同了。

我得到的错误是:

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/u5558315/public_html/admin/index.php:1) in /home/u5558315/public_html/admin/includes/php/header.php on line 3

我看过PHP开始标记前面和后面是否有空格,结束标记以及实际session_start()之前的任何内容。

session_start();是PHP脚本在实际<?php标记之后的第一件事。 我也试过ob_start()但也无法解决错误。

的header.php

<?php
ob_start();
session_start();
include('includes/php/functions.php');
if (!isset($_SESSION['login'])) {
redirect('login.php');
}
$now = time(); // checking the time now when home page starts 
if($now > $_SESSION['expire']){
echo '<script type="javascript">
alert("Your Session Has Timedout");
</script>';
session_destroy();
}
ob_end_flush();
?>

的index.php

<?php
include('includes/php/header.php');
?>

其他StackOverflow问题建议的所有内容都无效。 我还有什么办法可以解决这个问题吗?

此致 蒂姆沃斯

2 个答案:

答案 0 :(得分:0)

重定向功能有什么作用?

错误显示第5行的内容。所以它具有重定向功能。

我认为这可以解决你的问题。

if (!isset($_SESSION['login'])) {
    header('location:login.php');
    exit;
} 

答案 1 :(得分:0)

老实说,我不知道我是如何修理它的,或者即使我修复了它,但它确实有效。

主机可能会在配置中更改某些内容以修复它,但老实说我不知道​​。

感谢您的回答