开发者

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

开发者 https://www.devze.com 2023-03-20 16:11 出处:网络
I开发者_开发问答 am developing a simple php/mysql discussion forum. The statement <?php print $_SESSION[\'username\']; ?>

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?


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号