为什么PHP跟不上页面之间的会话? [英] Why does PHP not keep session between pages?

查看:130
本文介绍了为什么PHP跟不上页面之间的会话?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Windows Server 2008的Apache2。该服务器有2光盘和我运行两个Apache的一个实例。首先作为服务运行在命令行第二。它们都使用相同的根目录的精确副本,在自己的htdocs文件夹。此外,他们都使用相同的PHP安装位于第一盘上(程序文件(x86))。我的应用程序运行在SSL和使用PHP和MySQL。

I have a Windows server 2008 with apache2. The server has 2 discs and I run an apache instance on both. The first runs as a service the second in the commandline. They both use an exact copy of an identical webroot in their own htdocs folder. Also they both use the same PHP install that is located on the first disc (Program Files (x86)). My application runs over SSL and uses PHP and MySQL.

运行作为服务运行我的应用程序精细,让我登录,我已经准备好随时会话数据的网络服务器。然而第二个服务器让我跑我的登录脚本,具有会话数据运行脚本一阵,但重定向到另一页相同的根目录里面就失去了会话数据。

The webserver that runs as a service runs my application fine and lets me login and has my session data ready at all times. The second server however lets me run my login script, has session data while running the script but loses that session data after a redirect to another page inside the same webroot.

在第二web服务器的问题是类似于<一href=\"http://stackoverflow.com/questions/415005/php-session-variables-not-carrying-over-to-my-logged-in-page-but-session-id-is\">this问题与我已经在session_start()除外每一页上。

The problem on the second webserver is similar to this question with the exception that I have session_start() on every page.

我的登录脚本是这样的:

My login script works like this:


  • 用户请求一个页面

  • 如果用户没有通过验证,他又回到了登录页面

  • 如果用户通过验证,他得到了$ _SESSION [AUTH]与他的个人资料数据

  • 然后,当用户浏览主页或需要身份验证的其他页面,他们只检​​查是否[AUTH]设置$ _SESSION。

如何解决这个任何提示?

Any tips on how to solve this?

修改小澄。我有在每一页上的会话ID。当我重定向该ID不会改变。我没有在我重定向到页面上的$ _SESSION变量的任何数据。

A small clarification. I do have a session ID on each page. That id does not change when I get redirected. I do NOT have any data in the $_SESSION variable on the page I redirect to.

推荐答案

看看那里正在存储会话文件的PHP会话目录的权限。如果PHP没有写权限,创建和更改文件,您将无法保存任何东西在你的$ _SESSION变种。

Look at the permissions of the php session directory where the files for the session are being stored. If php doesn't have the rights to write, create and change files you won't be able to store anything in your $_SESSION var.

这篇关于为什么PHP跟不上页面之间的会话?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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