1

我有一个问题,会话 ID 没有被写入。如果这个问题持续了很长时间,我很抱歉,但我已经做了很多测试来排除某些事情,所以认为展示我拥有的所有数据很有用。

对于每个测试,我都会在 Chrome 中打开一个新的隐身窗口,以确保在开始新测试之前清除 cookie/会话。

此外,请注意,我正在处理的网站在两个不同的文件夹中有两种不同的语言。英语和希伯来语。

网站的英文版一切正常,但希伯来文版却不行。一些“包含”文件位于一个名为 /php/ 的单独文件夹中,该文件夹同时包含在希伯来语和英语端。

不确定是否相关,但 .htaccess 文件包含英语和希伯来语方面的重定向,类似于:

RewriteEngine on

RewriteCond %{ENV:REDIRECT_STATUS} 200
RewriteRule .* - [L]

RewriteRule ^categories/(.+) /HE/categories.php?pg=$1&type=$2 [L]

在 php 页面本身(例如 categories.php)上,代码开始:

<?php include_once('header.php');

在 header.php 中,我有:

<?
require_once '../php/config.php';
require_once 'functions.php';

在希伯来语和英语双方都使用的 config.php 中,我有:

<?php
session_start();
echo "--".session_id();

在所有情况下,

当我转到页面时:

http://www.goo.com/HE/categories/foo

每次我刷新时,它都会为 session_id() 回显一个新值

在错误日志中,我得到:

[23-Oct-2013 04:12:41] PHP Warning:  session_start() [<a href='function.session-start'>function.session-start</a>]: Cannot send session cookie - headers already sent by (output started at /home/foo/public_html/HE/header.php:1) in /home/foo/public_html/php/config.php on line 2
[23-Oct-2013 04:12:41] PHP Warning:  session_start() [<a href='function.session-start'>function.session-start</a>]: Cannot send session cache limiter - headers already sent (output started at /home/foo/public_html/HE/header.php:1) in /home/foo/public_html/php/config.php on line 2

现在,我想再次强调,我知道没有空格,并且等效的空格似乎在英语方面工作没有问题。

我创建了一个名为 testess.php 的文件,其中包含:

<?php
session_start();
echo "--".session_id();

并将其放在 HE 文件夹中,这样可以正常工作而不会出现错误

我确信这真的很简单,但是几个小时以来一直在尝试不同的事情,我完全被难住了。

4

2 回答 2

2

Chek if your files are UTF-8. some text editors put a bit of code on begining of the UTF-8 files. Check if there is any extra character at the files you include.

于 2013-10-23T10:31:03.190 回答
1

你可以参考这个SO Question

可能这是一个 UTF-8 BOM(字节顺序标记)问题。如果可以访问 windows 环境,您可以使用 Notepad++ 删除 BOM:

  1. 在记事本++中打开文件
  2. 编码菜单中选择“在没有 BOM 的 UTF-8 中编码
  3. 然后保存
于 2013-10-27T12:45:59.607 回答