将相关文件移动到站点根目录后,基于会话的登录出现问题

发布于 2024-09-04 14:55:45 字数 206 浏览 4 评论 0原文

我有一个网站,我一直在客户网站根目录的子文件夹中进行测试。 我在测试过程中没有遇到登录问题,但后来我将新站点文件从子目录移动到主站点根目录,现在在安全区域中几乎每个页面刷新后我都失去了登录状态。

我正在运行一个基于 $_session 的登录系统,该系统会在每次页面加载时刷新会话 ID,并将比较值存储在 MySQL 数据库中。

有人对可能导致此问题的原因有建议吗?

I have a site which I have been testing in a sub-folder of my client's site-root.
I had no log in problems during testing, but then I moved the new site files from a sub-directory to the main site root, and now I'm losing my logged in state after almost every page refresh in secure areas.

I am running a $_session based login system that refreshes the session id on every page load, with a comparison value stored in the MySQL database.

Does anyone have suggestions for what could be causing this problem?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

丘比特射中我 2024-09-11 14:55:45

krico 正确地建议 cookie 路径可能是原因(但提出的解决方案似乎有点愚蠢),但你说过事实并非如此。

使用iehttpheaders (MSIE) LiveHeaders (Firefox) 或使用wireshark 等网络嗅探器检查确切正在设置和返回的cookie(名称、路径、过期、标志)。然后再次提出问题,提供您发现的详细信息。

C.

krico was right in suggesting that the cookie path may be the cause (but the solution proposed seems a bit daft) however you've said that is not the case.

Check to see exactly what cookies (name, path, expiry, flags) are being set and returned by using iehttpheaders (MSIE) LiveHeaders (Firefox) or using a network sniffer like wireshark. Then ask the question again providing details of what you found out.

C.

乜一 2024-09-11 14:55:45

Cookie 通常与路径相关。您之前基于子目录的站点可能仅为该子目录设置了 cookie(将浏览器绑定到用户)。

解决此问题的一种方法是在旧子目录上放置一个重定向页面,该页面将 cookie 添加到“/”,然后重定向到根目录上的新站点。

Cookies are usually path relevant. Your previous sub-directory based site was probably setting the cookie (that binds the browser to the user) only for that sub-directory.

A way to fix it is to put a redirection page on the old subdir that adds a cookie to '/' and then redirects to new site on root.

写下不归期 2024-09-11 14:55:45

如果更改会话 ID,您将丢失先前会话中存储的所有数据。您必须在每个会话启动命令后设置会话名称

<?php
session_name('AnySessName');
?>

,或使用其他机制来存储跨会话的变量。

If you change session id you will loose all data stored in previous session. You must set session name after every session start command

<?php
session_name('AnySessName');
?>

or use other mechanism to store your variables cross sessions.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文