跨页面传递会话变量 [英] Passing session variables across pages

查看:47
本文介绍了跨页面传递会话变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两台服务器正在运行,'A''用于测试和开发,

服务器''B'用于生产。

在服务器A上,我为登录用户编写了一个PHP测试代码,然后将它们指向

到个性化页面。这是通过3个步骤完成的:

步骤1.正常的http登录页面。

步骤2.一个名为login.php的页面,它采用已发布的用户名,存储

它为$ _SESSION [" username"],并注册它

session_register(" username");用户根据他的用户名被带到个性化页面

,这里的事情很好。 (此页面

不显示,仅用于重定向目的)。

步骤3.在个性化页面上,我检查会话是否已启动,

然后显示带有用户名的欢迎消息。会话变量

在页面上传递得很好。


接下来,我在服务器B上做了完全相同的步骤;在步骤2(上面)用户

被定向到正确的页面。但是当我进入第3步时,会话

似乎丢失或将其所有变量设置为NULL(我使用

var_dump($ _ SESSION)检查了这一点。) />

服务器A和B上的代码完全相同。我将php.ini文件

从服务器A复制到B(以防万一有差异)并重新启动

服务器B上的Apache。但是,会话变量仍然丢失在第3步中

虽然会话仍在运行。


任何想法为什么?

解决方案

_SESSION [" username"],并将其注册

session_register(" username");用户根据他的用户名被带到个性化页面

,这里的事情很好。 (此页面

不显示,仅用于重定向目的)。

步骤3.在个性化页面上,我检查会话是否已启动,

然后显示带有用户名的欢迎消息。会话变量

在页面上传递得很好。


接下来,我在服务器B上做了完全相同的步骤;在步骤2(上面)用户

被定向到正确的页面。但是当我进入第3步时,会话

似乎丢失或将其所有变量设置为NULL(我使用

var_dump(


_SESSION))。


服务器A和B上的代码完全相同。我将php.ini文件

从服务器A复制到B(以防万一有差异)并重新启动

服务器B上的Apache。但是,会话变量仍然丢失在第3步中

虽然会话仍在运行。


任何想法为什么?


ķ。 A. schrieb:


我有两台服务器正在运行,'A''用于测试和开发,以及

服务器''B ''用于制作。

在服务器A上,我为登录用户编写了一个PHP测试代码,然后将它们指向

到个性化页面。这是通过3个步骤完成的:

步骤1.正常的http登录页面。

步骤2.一个名为login.php的页面,它采用已发布的用户名,存储

as


I have two servers at work, ''A'' for testing and development, and
server ''B'' for production.
On server A, I wrote a PHP test code to login users then direct them
to a personalized page. This is done in 3 steps:
Step 1. Normal http login page.
Step 2. A page called login.php that takes the posted username, stores
it as $_SESSION["username"], and registers it
session_register("username"); user is taken to the personalized page
according to his username and things are fine up to here. (this page
is not displayed, only for redirecting purposes).
Step 3. On the personalized page, I check whether session is started,
then display a welcome message with the username. Session variables
are passed across pages fine.

Next, I did exactly the same steps on server B; at step 2 (above) user
is directed to the correct page. But when I get to step 3, the session
seems to lose or set all its variables to NULL (I checked this using
var_dump($_SESSION)).

The codes on server A and B are identical. I copied the php.ini file
from server A to B (just in case there were differences) and restarted
Apache on server B. But still, session variables are lost in Step 3
although the session is still running.

Any ideas why?

解决方案

_SESSION["username"], and registers it
session_register("username"); user is taken to the personalized page
according to his username and things are fine up to here. (this page
is not displayed, only for redirecting purposes).
Step 3. On the personalized page, I check whether session is started,
then display a welcome message with the username. Session variables
are passed across pages fine.

Next, I did exactly the same steps on server B; at step 2 (above) user
is directed to the correct page. But when I get to step 3, the session
seems to lose or set all its variables to NULL (I checked this using
var_dump(


_SESSION)).

The codes on server A and B are identical. I copied the php.ini file
from server A to B (just in case there were differences) and restarted
Apache on server B. But still, session variables are lost in Step 3
although the session is still running.

Any ideas why?


K. A. schrieb:

I have two servers at work, ''A'' for testing and development, and
server ''B'' for production.
On server A, I wrote a PHP test code to login users then direct them
to a personalized page. This is done in 3 steps:
Step 1. Normal http login page.
Step 2. A page called login.php that takes the posted username, stores
it as


这篇关于跨页面传递会话变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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