A strange session problem. let's share it with you.
A problem was found during a small project. after login, $ _ SESSION ['name'] = 'XXX' is displayed, no $ _ SESSION ['name'] is displayed on the page. However, after running some pages, the value of $ _ SESSION ['name'] has always changed to an inexplicable value. Finally, the problem is found. I made a small piece of code.
';echo $_SESSION['name'];$name = 'def';echo $_SESSION['name'];?>
Output abc press enter def
Why didn't abc press enter abc ??
I hope you will pay attention to it.
Reply to discussion (solution)
It's abc. press enter abc.
It's abc. press enter abc.
You have tested the code before. if you press abc to enter abc, it should be caused by different configuration files.
Abc press enter abc ..
I have some questions from the landlord,
Var_dump ($ _ SESSION); let's take a look.
I have some questions from the landlord,
Var_dump ($ _ SESSION); let's take a look.
Abc
Defarray (4) {["name"] => & string (3) "def" ["isLogin"]
Abc press enter abc .. Is it really a problem with the configuration file...
Abc press enter abc .. Php5?
It is probably a problem with php. ini.
I also tested it, that is, abc press enter abc.
Nothing!
In the same file, you assign a value before it and output it later.
This is not a problem. how can I set $ name = & $ _ SESSION ["name"]?
I cannot test register_globals = on here. php 5.4 has canceled this ini parameter.
Your first visit was abc press enter abc. please refresh it to see if it has changed.
Your first visit was abc press enter abc. please refresh it to see if it has changed.
Finally found the relevant blog
Http://m.baidu.com/from=0/bd_page_type=1/ssid=0/uid=C828E299E1B851FF5E3FA33C623D351B/pu=sz%401321_2003%2Cusm%400%2Cta%40utouch_1_6.1_1_8.9/w=0_10_%E6%94%B9%E5%8F%98session%E5%90%8D%E7%9A%84%E5%8F%98%E9%87%8F%EF%BC%8Csession%E8%AF%A5%E5%80%BC%E8%B7%9F%E7%9D%80%E5%8F%98 php/t = wap/l = 3/tc? Ref = www_utouch & lid = 2077429663204035615 & order = 9 & vit = osres & tj = www_normal_9_0_10 & m = 8 & dict = 2 & sec = 30152 & di = Hangzhou & bdenc = 1 & nsrc = I-DV_wEptyoA_yixCFOxXnANedT62v3IJBaOMmBXATq5953ybrWxBcJpX5zsQnqTHYCb9m3QdMZSbCGu0VByj2YKh4AnxmdN8XXbb4zuga