简体   繁体   English

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

[英]session variables lost between pages or use same variables

Hi and happy new years to everybody, 祝大家新年快乐

I have Wamp Server(2.2.11) with PHP(5.2.9.-2). 我有Wamp Server(2.2.11)和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. 我使用不同的用户ID测试同一应用程序。 When I use "session.use_cookies = 0", session variables lost between pages for SAME UserID. 当我使用“ session.use_cookies = 0”时,会话变量在SAME UserID的页面之间丢失。 When I use "session.use_cookies = 1", same session variables are used DIFFERENT User IDs. 当我使用“ session.use_cookies = 1”时,将使用相同的会话变量作为不同的用户ID。

My php.ini's session settings at below: 我的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"

What is my mistake? 我怎么了 Thanks for all responses from now. 感谢您从现在开始的所有回复。

Best regards. 最好的祝福。

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. 如果关闭cookie,则PHP必须使用trans_sid方法,该方法将会话ID嵌入为查询参数和隐藏的表单字段。 Your trans_sid is set to 0 (off), so with cookies turned off, you've essentially disabled sessions outright. 您的trans_sid设置为0(关闭),因此关闭Cookie后,您实际上已经彻底禁用了会话。

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. 至于每次获取一个新的ID,请使用Firebug或HTTPFox之类的东西来查看服务器和浏览器之间的来回变化。 If the browser isn't returning the session cookie with each request, PHP has no choice but to start a new session each time. 如果浏览器未随每个请求返回会话cookie,则PHP别无选择,只能每次启动一个新会话。

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

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