会话变量在页面之间丢失或使用相同的变量 [英] session variables lost between pages or use same variables

查看:57
本文介绍了会话变量在页面之间丢失或使用相同的变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,新年快乐,

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

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.

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

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.

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

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.

最好的问候.

推荐答案

如果关闭 cookie,那么 PHP 就不得不使用 trans_sid 方法,该方法将 session ID 嵌入为查询参数和隐藏表单领域.您的 trans_sid 设置为 0(关闭),因此关闭 cookie 后,您实际上已经彻底禁用了会话.

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.

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

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.

这篇关于会话变量在页面之间丢失或使用相同的变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆