PHP会话中的错误数据 [英] wrong data in PHP session

查看:64
本文介绍了PHP会话中的错误数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为网上商店进行了以下设置:
当用户登录时,将通过AJAX调用脚本,该脚本将根据SOAP-Webservice
验证用户数据并返回用户数据。用户登录后,用户数据将保存在PHP会话中。用户数据
仅由SOAP检索,而不由商店存储。我使用默认的PHP Session处理程序。
用户下订单时,确认电子邮件将发送到用户的地址。
该网站的流量适中,每天大约有100个订单。

I have the following setup for a webshop: When a user logs in, a script is called via AJAX, which validates the user data against a SOAP-Webservice and returns the user data. While the user is logged in, user data is saved in the PHP Session. User data is only retrieved by SOAP and not stored by the shop. I use the default PHP Session handler. When a user places an order, a confirmation email is sent to the users' address. The amount of traffic on the site is moderate, about 100 orders per day.

我有以下错误:
每三个月大约一次将电子邮件发送到错误的地址。
电子邮件正文中来自会话的其他数据(例如customerNo)是正确的,但显然电子邮件地址的值是错误的。

I have the following bug: Roughly once in three months an email is sent to the wrong address. Other data from the session in the email body (ex.customerNo) are correct but apparently the value of the email address is wrong.

此处到目前为止,我的发现是这样的:
每次发生这种情况时,地址混杂的用户都会在同一时间(+ 2秒)登录。
我尝试通过同时登录两个不同的用户并比较会话数据
来尝试重现此错误。

Here is what I found out so far: Each time this happened, the users whose addresses got mixed up, had logged in at the exact same time (+- 2 seconds). I unsuccessfully tried to reproduce this by logging in with two different users at the same time and comparing the Session data.

假定返回的数据来自SOAP-Webservice的消息是正确的,什么原因可能导致此问题?

Assuming the data returned from the SOAP-Webservice is correct, what could cause this problem?

编辑:这是用于编写和读取Session的代码段,其中的电子邮件位是在上下文之外,我省略了以下内容:

Here are the code snippets for writing and reading form the Session en the email bit the code is out of context, I left out bit in between:

EDIT2:删除了代码片段,因为问题原来是被称为的SOAP-Service实现中的缓存错误。

Removed the code snippets as the problem turned out to be a caching error in the SOAP-Service implementation called to retrieve email data.

推荐答案


每次发生这种情况时,地址混杂的用户都有恰好在同一时间(+/- 2秒)登录。我尝试通过同时登录两个不同的用户并比较会话数据来尝试重现此错误。

Each time this happened, the users whose addresses got mixed up, had logged in at the exact same time (+- 2 seconds). I unsuccessfully tried to reproduce this by logging in with two different users at the same time and comparing the Session data.

您描述的问题发生这种情况的原因很可能是由于过度的缓存和/或一端或另一端的数据泄漏问题。

The problem you describe has most likely arisen because of overzealous caching and / or problems with data leakage at one end or the other.

我认为,会话不太可能在会话开始时变得混乱PHP结束-但是您的代码中的会话别名可能存在问题。了解您的PHP实例是否以分叉的进程或线程运行会很有帮助。

I think its very unlikely that the sessions are getting confused at the PHP end - however there may be problems with session aliasing in your code. It would have been helpful to know if your PHP instances are running as forked processes or threads.

测试问题是否在远程服务器上的正确方法(即远程服务器使用线程的可能性要大得多)是对操作进行脚本编写-不使用浏览器-并使用不同的凭据对运行测试数百次-而不是一次。

The right way to test if the problem is on the remote server (which is significantly more likely of the remote server uses threading) is to script the operation - NOT use a browser - and run the test hundreds of times with different pairs of credentials - not just once.

这篇关于PHP会话中的错误数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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