会话变量适用于本地服务器,但不适用于托管服务器
我正在开发一个简单的 php/mysql 论坛.声明
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?
可能导致这种情况的一件事是,如果实时 Web 服务器位于使用默认 php 会话处理的负载平衡环境中.默认情况下,php 将会话数据存储在服务器上的平面文件中,因此如果用户在 webheads 周围跳转,他们将丢失会话数据.
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.
在这种情况下,您需要使用 db 定义自己的会话处理程序
in that case you will need to define your own session handler using a db