页面之间的会话变量丢失或使用相同的变量

发布于 2024-10-10 04:37:00 字数 1144 浏览 3 评论 0原文

大家好,新年快乐,

我有 Wamp Server(2.2.11) 和 PHP(5.2.9.-2)。 我知道我做错了,但我没有找到自己。在我写这封电子邮件之前,我用不同的搜索项目红色了许多文档。

我使用不同的用户 ID 测试同一应用程序。 当我使用“session.use_cookies = 0”时,同一用户ID的页面之间的会话变量丢失。 当我使用“session.use_cookies = 1”时,相同的会话变量使用不同的用户 ID。

我的 php.ini 会话设置如下:

[Session]
session.save_handler = files
session.save_path = "c:/wamp/tmp"
session.use_cookies = 1
;session.cookie_secure =
;session.name = PHPSESSID
session.auto_start = 0
session.cookie_lifetime = 0
session.cookie_path = /
session.cookie_domain =
session.cookie_httponly = 
session.serialize_handler = php
session.gc_probability = 1
session.gc_divisor     = 1000
session.gc_maxlifetime = 1440
session.bug_compat_42 = 0
session.bug_compat_warn = 1
session.referer_check =
session.entropy_length = 0
session.entropy_file =
;session.entropy_length = 16
;session.entropy_file = /dev/urandom
session.cache_limiter = nocache
session.cache_expire = 180
session.use_trans_sid = 0
session.hash_function = 0
session.hash_bits_per_character = 5
url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=fakeentry"

我的错误是什么?感谢您现在的所有回复。

此致。

Hi and happy new years to everybody,

I have Wamp Server(2.2.11) with PHP(5.2.9.-2).
I know I did something wrong but I didn't find myself. Before I wrote this e-mail I red many document with different search items.

I test a same application with different User IDs.
When I use "session.use_cookies = 0", session variables lost between pages for SAME UserID.
When I use "session.use_cookies = 1", same session variables are used DIFFERENT User IDs.

My php.ini's session settings at below:

[Session]
session.save_handler = files
session.save_path = "c:/wamp/tmp"
session.use_cookies = 1
;session.cookie_secure =
;session.name = PHPSESSID
session.auto_start = 0
session.cookie_lifetime = 0
session.cookie_path = /
session.cookie_domain =
session.cookie_httponly = 
session.serialize_handler = php
session.gc_probability = 1
session.gc_divisor     = 1000
session.gc_maxlifetime = 1440
session.bug_compat_42 = 0
session.bug_compat_warn = 1
session.referer_check =
session.entropy_length = 0
session.entropy_file =
;session.entropy_length = 16
;session.entropy_file = /dev/urandom
session.cache_limiter = nocache
session.cache_expire = 180
session.use_trans_sid = 0
session.hash_function = 0
session.hash_bits_per_character = 5
url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=fakeentry"

What is my mistake? Thanks for all responses from now.

Best regards.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

や莫失莫忘 2024-10-17 04:37:00

如果您关闭 cookie,则 PHP 必须使用 trans_sid 方法,该方法将会话 ID 嵌入为查询参数和隐藏表单字段。您的 trans_sid 设置为 0(关闭),因此在关闭 cookie 的情况下,您实际上已经完全禁用了会话。

至于每次获取新的 ID,请使用 Firebug 或 HTTPFox 之类的工具来查看服务器和浏览器之间的来回情况。如果浏览器没有在每个请求中返回会话 cookie,PHP 就别无选择,只能每次都启动一个新会话。

If you turn off cookies, then PHP has to use the trans_sid method, which embeds the session ID as query parameters and hidden form fields. Your trans_sid is set to 0 (off), so with cookies turned off, you've essentially disabled sessions outright.

As for getting a new ID each time, use something like Firebug or HTTPFox to see what's going back and forth between your server and the browser. If the browser isn't returning the session cookie with each request, PHP has no choice but to start a new session each time.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文