Session variable works on local server, but not on hosting server

ε祈祈猫儿з 提交于 2019-12-07 19:37:03

问题


I am developing a simple php/mysql discussion forum. The statement

<?php print $_SESSION['username']; ?> 

produces the desired results on my local machine, but when I uploaded the code to test the forum live, the value of the session variable no longer displayed. What could be causing this?


回答1:


one thing that can cause this is if the live web server is on a load balanced environment using default php session handling. By default php stores session data in a flat file on ther server so if the user is jumping around webheads they will lose session data.

in that case you will need to define your own session handler using a db



来源:https://stackoverflow.com/questions/6720795/session-variable-works-on-local-server-but-not-on-hosting-server

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