警告:session_start()[function.session-start]:无法发送会话缓存限制器 [英] Warning: session_start() [function.session-start]: Cannot send session cache limiter

查看:91
本文介绍了警告:session_start()[function.session-start]:无法发送会话缓存限制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在这里的Session_start()有问题:

I have a problem with Session_start() here :

警告:session_start()[function.session-start]:无法发送会话缓存限制器-标头已发送(输出从C:\ xampp \ htdocs \ pages \ home.php:4开始)在 2

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\xampp\htdocs\pages\home.php:4) in C:\xampp\htdocs\charts\home-chart.php on line 2

在第2行的home-chart.php中,我编写了如下代码:

and in home-chart.php in line 2 I wrote codes like this :

session_start();
.
.
.
echo ' username: '.$_SESSION['user_name'];


尽管收到此警告,我仍可以得到$_SESSION['user_name']的结果,但是当我尝试清除这部分代码时:


although with this warning i can get result of $_SESSION['user_name'] but when I try to clear this part of the code :

session_start();

我在屏幕上看不到任何结果. 那么,您的解决方案是什么?

I can't see any result in screen. so, what's your solution?

<?php
@session_start();
require_once '../class/chart.class.php';
$chart = new chart();
?>
<html>
    <head>
        <link href='../css/home-chart.css'  rel='stylesheet' type='text/css' />
    </head>
    <body>
        <div class='float_left' style="margin-bottom:20px;">
            <div class='float_left' style='line-height: 9.41px; font-size: x-small;'>0<br /></div>      <div class='float_left' style="background-image: url('../image/web/chart.png'); width: 367px; height: 226px; " >
                <!-- 1 --><div class='float_left float_left column' style='margin-left:2px;'>
                    <?php echo $chart->mysql_fetch($chart->daycal(-3)); ?>
                </div>  
                <!-- 2 --><div class='float_left float_left column'>
                    <?php echo $chart->mysql_fetch($chart->daycal(-2)); ?>
                </div>  
                <!-- 3 --><div class='float_left column' >
                    <?php echo $chart->mysql_fetch($chart->daycal(-1)); ?>
                </div>  
                <!-- 4 --><div class='float_left column' >
                    <?php echo $chart->mysql_fetch($chart->daycal(0)); ?>
                </div>  
                <!-- 5 --><div class='float_left column' >
                    <?php echo $chart->mysql_fetch($chart->daycal(1)); ?>
                </div>  
                <!-- 6 --><div class='float_left column' >
                    <?php echo $chart->mysql_fetch($chart->daycal(2)); ?>
                </div>  
                <!-- 7 --><div class='float_left column' >
                    <?php echo $chart->mysql_fetch($chart->daycal(3)); ?>
                </div>  
            </div>


            <div class='float_single_full' ></div>
            <div class='float_left bottom_chart' style="margin-left:10px;"><?php echo $chart->dayofweek(-3); ?></div>
            <div class='float_left bottom_chart'><?php echo $chart->dayofweek(-2); ?></div>
            <div class='float_left bottom_chart'><?php echo $chart->dayofweek(-1); ?></div>
            <div class='float_left bottom_chart'  style='font-weight:bold'><?php echo $chart->dayofweek(0); ?></div>
            <div class='float_left bottom_chart'><?php echo $chart->dayofweek(1); ?></div>
            <div class='float_left bottom_chart'><?php echo $chart->dayofweek(2); ?></div>
            <div class='float_left bottom_chart'><?php echo $chart->dayofweek(3);
                    echo ' username: ' . $_SESSION['user_name'];
                    ?></div>
        </div>
    </body>
</html>

推荐答案

如果您甚至在<?php标记之前都留有空白行,则无法设置标题.您的文件开头(带有行号)应如下所示:

If you even have blank lines before the <?php tag, then you can't set headers. Your start of file, with line numbers, should look like this:

1. <?php
2. session_start();
3. header('Cache-control: private');

该消息显示在第2行发送了标头",因此您正在home.php的第4行输出某些内容(空格,空白行等)

The message says "headers sent at line 2", so you're outputting something (a space, a blank line, whatever) on line 4 of home.php

如果此文件为包含文件,则应将session_start();放在home.php的顶部,然后在此文件中不需要它.

If this file is an include, you should put your session_start(); at the top of home.php instead, and then you don't need it in this file.

这篇关于警告:session_start()[function.session-start]:无法发送会话缓存限制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆