如何检测用户是否为同一会话打开两个选项卡?
我使用 CakePHP 完成了一个预订应用程序,其中涉及到结帐页面之前的几个步骤.在这些步骤之间,我将信息存储在会话中.
I've done a booking application done using CakePHP which involves a few steps before the checkout page. In between these steps I store the information in the session.
它的工作原理是第 1 步要求他们填写信息.进入第 2 步时,第 1 步中的信息将被保存到会话对象中.当他们继续进行其他步骤时,该过程会重复.最后结账时,所有数据都会保存到数据库中.
How it works is that Step 1 requires them to fill in their information. When going to Step 2, the information in Step 1 will be saved into the session object. As they proceed in the other steps, the process repeats. At the end when they checkout, all the data is then saved to the database.
如果用户在浏览器中打开应用程序的一个实例,一切都会很好.但是,一旦他们在同一个浏览器中为同一个应用程序打开了另一个页面或另一个选项卡,就会出现问题.
Everything works great if the user opens one instance of the application in the browser. But once they have another page or another tab opened for the same application in the same browser, problem happens.
假设他们在选项卡 A 和选项卡 B 中打开了两个应用程序实例.在选项卡 A 中,他们在步骤 1 中输入了详细信息并继续执行步骤 2.然后用户在选项卡 B 中执行相同的操作.
Let's say they have two instance of the application open in Tab A and Tab B. In Tab A they entered the details in Step 1 and proceed to Step 2. Then the user does the same thing in Tab B.
在用户结帐的最后一步,Tab A 中的信息与 Tab B 中的信息相同.
At the last step when the user does a checkout, information in Tab A is the same as in Tab B.
目前,我只能认为最好的方法是防止用户在两个浏览器实例中打开同一个应用程序.
Right now, I can only think the best way is to prevent the user from opening the same application in two browser instance.
当用户尝试在选项卡 B 中打开另一个实例时,是否有办法检测并提示用户先在选项卡 A 中填写预订表单?
Is there a way to detect and prompt the user to complete the booking form in Tab A first when they try to open another instance in Tab B?
推荐答案
1.同样的问题(及解决方案):https://sites.google.com/site/sarittechworld/track-client-windows
1.The same problem (and solution) : https://sites.google.com/site/sarittechworld/track-client-windows
2.您可以通过POST或GET方式发送信息
2.You can send information by POST or GET
相关文章