会话变量适用于本地服务器,但不适用于托管服务器 [英] Session variable works on local server, but not on hosting server

查看:57
本文介绍了会话变量适用于本地服务器,但不适用于托管服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个简单的 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

这篇关于会话变量适用于本地服务器,但不适用于托管服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆