如何检测用户是否为同一会话打开了两个选项卡? [英] How to detect if user open two tabs for same session?

查看:74
本文介绍了如何检测用户是否为同一会话打开了两个选项卡?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经完成了使用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.

在用户结帐的最后一步,选项卡A中的信息与选项卡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

这篇关于如何检测用户是否为同一会话打开了两个选项卡?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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