session variables lost between pages or use same variables

眉间皱痕 提交于 2019-12-11 18:12:46

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/4579185/session-variables-lost-between-pages-or-use-same-variables

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!