跨页面传递会话变量

编程入门 行业动态 更新时间:2024-10-27 01:32:16
本文介绍了跨页面传递会话变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有两台服务器正在运行,'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

更多推荐

跨页面传递会话变量

本文发布于:2023-10-11 22:20:21,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1483003.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:变量   页面

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!