gpt4 book ai didi

PHP session 不工作

转载 作者:可可西里 更新时间:2023-11-01 13:20:13 26 4
gpt4 key购买 nike

我正在使用 wamp2.0 - PHP 5.3、apache 2.2.11,但我的 session 没有存储数据。

我有一个接受参数的页面,我想将其(简化版)存储在 session 中,所以当我来

http://www.example.com/home.php?sessid=db_session_id

脚本如下:

session_start();

$sessid = @$_GET['sessid'];
if ($sessid) {
$_SESSION['sessid'] = $sessid;
}
var_dump($_SESSION);

和输出:

array(1) { [0]=> string(13) "db_session_id" } 

这很好,但是当我转到 link 时(没有 sessid 参数)$_SESSION 数组为空。我曾尝试在不带参数的情况下转到页面之前评论 $_SESSION['sessid'] = $sessid; 行,但它仍然没有用。

我检查了 session_id() 输出, session ID 保持不变。

来自 phpinfo() 的 session 设置

Session Support enabled
Registered save handlers files user
Registered serializer handlers php php_binary wddx

Directive Local Value Master Value
session.auto_start Off Off
session.bug_compat_42 On On
session.bug_compat_warn On On
session.cache_expire 180 180
session.cache_limiter nocache nocache
session.cookie_domain no value no value
session.cookie_httponly Off Off
session.cookie_lifetime 0 0
session.cookie_path / /
session.cookie_secure Off Off
session.entropy_file no value no value
session.entropy_length 0 0
session.gc_divisor 1000 1000
session.gc_maxlifetime 1440 1440
session.gc_probability 1 1
session.hash_bits_per_character 5 5
session.hash_function 0 0
session.name PHPSESSID PHPSESSID
session.referer_check no value no value
session.save_handler files files
session.save_path c:/wamp/tmp c:/wamp/tmp
session.serialize_handler php php
session.use_cookies On On
session.use_only_cookies On On
session.use_trans_sid 0 0

编辑:

The sessions are deleted by an iframe. I don't know why, but when commented, the sessions work fine. Thing is, the iframe has to stay there (which of course is bad, but I can't do anything about it). Well...do you know about any workarounds to get the sessions working with an iframe?

最佳答案

这是一个老问题,但我带着同样的问题来到这里。由于问题没有得到解答,所以我找到了。

我有一个类似的问题,在我的例子中,问题是我没有调用 session_start()在使用 session 的所有页面中。我以为我应该只在“登录”页面调用它,但事实并非如此。

此外,请记住 session_start()必须在 <html> 之前调用标签。

关于PHP session 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4614671/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com