PHP session_start() 无法创建会话 [英] PHP session_start() fails to create session

查看:55
本文介绍了PHP session_start() 无法创建会话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我在 index.php 中的前 5 行:

These are my first 5 lines in my index.php:

  <?php
session_start();
if (!isset($_SESSION['cart'])) $_SESSION['cart']='';
$page = $_GET['page'];
?>

等等..我正在通过 firefox->firebug->firecookie 插件查看会话,但未创建会话.(我确信这一点,因为昨天工作的购物车今天不起作用.)任何想法为什么会发生这种情况以及如何解决它?

and so on.. I'm looking at the sessions trough the firefox->firebug->firecookie plugin and a session is not created.(I am sure of it because the cart that worked yesterday doesnt work today.) Any ideas why this might happen and how to fix it ?

我在启用错误时发现了这一点:警告:session_start() [function.session-start]:无法发送会话 cookie - 头文件已由/home/controll/public_html 中的(输出开始于/home/controll/public_html/metalkonsult.com/index.php:1)发送/metalkonsult.com/index.php 第 2 行

I found this when enabling errors: Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/controll/public_html/metalkonsult.com/index.php:1) in /home/controll/public_html/metalkonsult.com/index.php on line 2

我进一步探索 - 一些东西被发送到浏览器,但我不知道它来自哪里.我做了一个 var_dump(headers_list());在第一行,这就是我得到的:

I explored further - something IS sent to the browser but I dont know where its coming from. I did a var_dump(headers_list()); on the first line and this is what I get:

array(2) { [0]=> string(23) "X-Powered-By: PHP/5.2.6" [1]=> string(23) "Content-type: text/html" }

如何关闭此功能?发送的是什么?

How do I turn this off ? What's sending it ?

我设置 session.auto_start = 1在网站文件夹中的 php.ini 中会议现在工作..不知道是什么原因导致的问题,但问题已暂时修复

I set session.auto_start = 1 in php.ini in the website folder sessions work now.. dont know what caused the problems but problem is temporarily fixed

推荐答案

有东西首先发送到浏览器,导致发送标头.检查您的代码以确保您的 PHP 代码前没有一个空格.

Something is being sent to the browser first which is causing the headers to be sent. Check your code to make sure that there isn't even a single space before your PHP code.

这篇关于PHP session_start() 无法创建会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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