IE8 丢失一些 php 会话变量,同时在刷新或 ajax 调用时保持其他完整

发布于 2025-01-04 17:13:47 字数 1205 浏览 0 评论 0原文

这里 IE8 上的 php 会话有一个大问题。我在网上做了一些研究,但没有匹配的示例(或者我无法将它们翻译到我的场景中)

我有一个网站,它广泛使用具有多个值的会话和保存在会话变量中的数组。在 Chrome 和 Firefox 上一切正常,但系统的某些部分在 IE8 上崩溃,因为它似乎在刷新后丢失了会话信息。站点上的所有会话变量都会经历相同的各种操作,包括标头(位置)重定向、apache url 重写等。

但并非所有会话变量。这是一个例子。当我登录并将信息保存到会话(例如$_SESSION['user'])时,它在整个站点中工作正常并且我没有被注销($_SESSION['user'] 没有丢失) 。同时,我分配了不同的会话变量,即使登录变量仍然存在,它们也可能在刷新时丢失

这是一些在 IE8 上不起作用的部分的代码

1)我在页面上有一个链接,允许要编辑您正在查看的页面,假设链接是 /edititem/ID

2) 单击它会链接到一个 php 文件,该文件检索项目的数据并保存会话 var 数组。该数组中的字段之一决定哪些 html 元素将显示在编辑表单上。设置会话变量后,会出现 header() 重定向

    session_start();
    $item = Item::getById($_GET["id"]);
    $_SESSION["item"]["type"] = $item->type;
    $_SESSION["item"]["title"] = $item->title;
    $_SESSION["item"]["action"] = "edit";
    header('location: /item_management');

3) 当重定向后登陆 IE8 上的 /item_management 页面时,一切正常。当我刷新该页面时,上面设置的会话信息消失了,

我读到有关 IE8 上包含 _ 的 url 可能存在的问题。我在某个阶段更改了这些网址以使用 - 而不是 _ 但这没有帮助,所以我恢复了。 我还认为会话中的数组可能存在一些问题,但是代码中至少还有一个地方在 ajax 调用中调用时会丢失非数组会话(我有 $_SESSION["image"],执行 ajax调用,读取 php 中使用 ajax 调用的“image”变量,它是空的)。

此外,用户会话变量在整个系统中完好无损,即使其他值丢失了

所有与会话相关的东西在 chrome/firefox 上都能完美运行

有什么想法吗?我将提供所需的任何代码

Have a big problem with php sessions on IE8 here. I've done some research on the web but no examples match (or I'm not capable of translating them into my scenario)

I have a site that makes an extensive use of session having multiple values and an array kept in session vars. Everything works fine on chrome and firefox but parts of the system break on IE8 as it seems to simply loose session information after refresh. All session vars on the site go through the same various actions including header(location) redirections, apache url rewrite etc.

Not all sessions vars tho. Here's example. When I log in and save an information to a session (eg.$_SESSION['user']), it works fine throughout the site and I'm not being logged out ($_SESSION['user'] is not being lost). A the same time tho I'm assigning different session vars and they can be lost on refresh even tho login var is still present

Here's some code for the part that doesn't work on IE8

1) I have a link on the page that allows to edit page you're viewing, let say link is /edititem/ID

2) clicking it links to a php file that retrieves item's data and saves a session var array. One of the fields in that array determines which html elements will be displayed on the edit form. After session vars are set up, there's a header() redirection

    session_start();
    $item = Item::getById($_GET["id"]);
    $_SESSION["item"]["type"] = $item->type;
    $_SESSION["item"]["title"] = $item->title;
    $_SESSION["item"]["action"] = "edit";
    header('location: /item_management');

3) when landing on /item_management page on IE8 following that redirection, everything is ok. When I refresh that page tho, that session information set above is gone

I read about possible problems with urls that include _ on IE8. I changed those urls at some stage to use - instead of _ but that didn't help, so I reverted.
I was also thinking it may be some problem with arrays in session but there's at least one more place in the code where non-array session is being lost when called in ajax call (I have $_SESSION["image"], do an ajax call, read that 'image' var in php called with ajax and it's empty).

Also, user session var is intact throughout the system, even tho other values go missing

All session related stuff works perfect on chrome/firefox

Any ideas? I will provide any piece of code required

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

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

发布评论

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

评论(1

老娘不死你永远是小三 2025-01-11 17:13:47

我注意到我的内部网络应用程序也存在同样的问题。某些会话变量,尤其是刚刚更新到数据库中的变量,在刷新时会丢失,甚至会恢复为变量的旧值。我还没有找到解决方案,所以我一直让我的用户使用与 IE 不同的浏览器。

因此,我想唯一的解决方案是让人们知道 IE 有奇怪的行为,如果使用您的应用程序,他们应该尝试使用不同的浏览器。

I have noticed the same problem with my internal web application. Certain session variables, especially ones that were just updated into the database go missing upon refresh or even revert to older values of the variable. I have not found a solution so I've been having my users use a different browser than IE.

So I guess the only solution if you can is to let people know that IE has strange behavior and they should try to use a different browser if using your application.

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