简体   繁体   English

PHP 中的 Session_start 警告

[英]Session_start warning in PHP

That's the message i'm receiving:这就是我收到的信息:

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /var/www/new/login.php:1) in /var/www/new/login.php on line 3

And that's the exactly code:这就是确切的代码:

<?php
if(!isset($_SESSION))
    session_start();
ob_start();

No spaces before, no nothing.前面没有空格,什么都没有。 What's wrong here?这里有什么问题?

Are you sure your file is not saved in UTF-8 with BOM?您确定您的文件没有保存在带有 BOM 的 UTF-8 中吗? Try saving UTF-8 without BOM .尝试在没有 BOM 的情况下保存 UTF-8

Check that you have no BOM unicode set in your file, it's a common error of this type.检查您的文件中是否没有设置 BOM unicode,这是这种类型的常见错误。 If no BOM is there, have you any auto included file via htaccess or phpini php_auto_prepend?如果没有 BOM,你有没有通过 htaccess 或 phpini php_auto_prepend 自动包含的文件?

check your php configuration for session.auto_start, if this is enabled, you have already an open session.检查 session.auto_start 的 php 配置,如果启用,您已经打开了 session。

alternatively try this:或者试试这个:

if (empty(session_id())) {
    session_start(); // if no active session we start a new one
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM