简体   繁体   English

无法将数据存储到会话

[英]Cannot store data to session

I cant carry my session throughout files. 我无法进行整个文件的会话。

I checked 我检查了

  • I have session_start() at the beginning of each file 我在每个文件的开头都有session_start()

  • Used notepad, so no unseen BOM characters added by IDE 使用了记事本,因此IDE不会添加看不见的BOM字符

  • No error, warning etc. 没有错误,警告等。

  • Sessions are enabled (see phpinfo() output below ) 启用了会话(请参见下面的phpinfo()输出)

  • No rewrites etc. 没有重写等

So my files are as follows 所以我的文件如下

a.php: a.php:

session_start();
$_SESSION["test"] = "value";
header("Location: b.php");
exit;

b.php b.php

session_start();
echo "session: ";
print_r($_SESSION);

output of b.php : b.php输出:

session: Array ()

phpinfo() output: phpinfo()输出:

在此处输入图片说明

(Also session_id() is same in both files, and I have a session cookie file.) (两个文件中的session_id()也相同,并且我有一个会话cookie文件。)

Only thing I can think of is session save path may not have write permission, but this is a shared host, so I assume this is not the case (I'll check with the host porvider anyway) 我唯一能想到的是会话保存路径可能没有写权限,但是这是一个共享主机,因此我认为情况并非如此(无论如何我都会与主机porvider一起检查)

What am I missing here? 我在这里想念什么?

on page b.php 在b.php页上

use this code 使用此代码

session_start();
echo $_SESSION["test"];

instead of 代替

session_start();
echo "session: ";
print_r($_SESSION);

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

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