问题
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