不寻常的会话行为 [英] Unusual Session Behaviour

查看:42
本文介绍了不寻常的会话行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在两个不同的
服务器上使用会话时发现非常不寻常的行为。


我正在使用会话来处理简单的登录当表单提交

值时,将根据MySQL表进行检查。如果匹配存在两个会话

变量:$ _SESSION [''db_is_logged_in'']和

$ _SESSION [''user'']。每个页面检查会话变量

''db_is_logged_in''是否设置为true,否则显示页面否则使用

header重定向到错误页面。


这在本地和其他服务器上运行良好。

最近我移动了服务器,从那时起整个身份验证过程

一直表现异常。有时(登录时)您将被带到错误页面,但您的用户名仍显示在菜单中。

再点击链接几次,最终页面将正确显示




我的问题是,有什么选项或原因可以解释为什么现在以前工作正常的b $ b工作正常太不可靠了?我正在使用session_start()和

这在一台服务器上工作得很好,为什么不在另一台服务器上呢?

PHP的版本甚至是相同的(4.3.2)。


这让我难倒了好几天了,我不是更接近解决

它,我真的很感激任何建议。提前致谢。

解决方案

_SESSION [''db_is_logged_in'']和


_SESSION [ '' 用户 '']。每个页面检查会话变量

''db_is_logged_in''是否设置为true,否则显示页面否则使用

header重定向到错误页面。


这在本地和其他服务器上运行良好。

最近我移动了服务器,从那时起整个身份验证过程

一直表现异常。有时(登录时)您将被带到错误页面,但您的用户名仍显示在菜单中。

再点击链接几次,最终页面将正确显示




我的问题是,有什么选项或原因可以解释为什么现在以前工作正常的b $ b工作正常太不可靠了?我正在使用session_start()和

这在一台服务器上工作得很好,为什么不在另一台服务器上呢?

PHP的版本甚至是相同的(4.3.2)。


这让我难倒了好几天了,我不是更接近解决

它,我真的很感激任何建议。在此先感谢。


确保经过身份验证的所有文件都在伞在顶部有
session_start()。

介意的唯一另一件事是,如果你的网页不是全部在同一个服务器/域上,那么

会导致浏览器有多个会话ID''秒。还要检查确定

PHPSESSIONID变量在php.ini中配置为通过

cookie而不是url传递。


Alex
http://prepared-statement.blogspot.com
http://learn2host.blogspot.com


I''ve found very unusual behavious when using sessions on two different
servers.

I''m using sessions to handle simple log in. When the form submits the
values are checked against a MySQL table. If a match exists two session
variables are created: $_SESSION[''db_is_logged_in''] and
$_SESSION[''user'']. Each page checks if the session variable
''db_is_logged_in'' is set and is true, display the page otherwise use
header to redirect to an error page.

This worked all well and fine locally, and on one other server.
Recently I moved server and since then the whole authentication process
has been behaving unusually. Sometimes (when logged in) you are taken
to the error page, but your username is still displayed in the menu.
Clicking the link a few more times and eventually the page will display
correctly.

My question is are there any options or reasons why what has previously
worked fine could now be so unreliable? I am using session_start(), and
this worked very well on one server, why not another? The versions of
PHP are even the same (4.3.2).

This has had me stumped for a few days now and I''m no closer to solving
it, I''d really appreciate any suggestions. Thanks in advance.

解决方案

_SESSION[''db_is_logged_in''] and


_SESSION[''user'']. Each page checks if the session variable
''db_is_logged_in'' is set and is true, display the page otherwise use
header to redirect to an error page.

This worked all well and fine locally, and on one other server.
Recently I moved server and since then the whole authentication process
has been behaving unusually. Sometimes (when logged in) you are taken
to the error page, but your username is still displayed in the menu.
Clicking the link a few more times and eventually the page will display
correctly.

My question is are there any options or reasons why what has previously
worked fine could now be so unreliable? I am using session_start(), and
this worked very well on one server, why not another? The versions of
PHP are even the same (4.3.2).

This has had me stumped for a few days now and I''m no closer to solving
it, I''d really appreciate any suggestions. Thanks in advance.


Make sure all of the files inside the "authenticated" umbrella have
session_start() on it at the top. The only other thing that comes to
mind is if your pages are not all on the same server/domain, that would
cause the browser to have multiple session id''s. Also check to be sure
the PHPSESSIONID variable is configured in php.ini to be passed via
cookie instead of url.

Alex
http://prepared-statement.blogspot.com
http://learn2host.blogspot.com


这篇关于不寻常的会话行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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