创建浏览器选项卡特定cookie [英] creating browser tab specific cookie

查看:90
本文介绍了创建浏览器选项卡特定cookie的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用交易网站。

我在cookie中存储交易标识符(唯一ID),以便我可以向用户显示交易历史记录。


现在有一天现代浏览器在同一个窗口中支持多个标签。



有什么办法可以创建特定于标签的cookie吗?哪个在另一个标签中无法访问?或者是否有任何标签的唯一标识符?


我正在使用java脚本创建cookie。

I am working on transactional website.
I am storing transaction identifier (a unique id) in a cookie, so that I can display transaction history to user.

Now a days modern browsers support multiple tabs in same window.

I am facing a problem when user starts two different transaction in two different tabs in same browser window. I am unable to differentiate between different browser tabs, because which same cookie is getting overwritten, in both the tabs.

Is there any way by which I can create tab specific cookie? which won''t be accessible in another tab? Or is there any unique identifier for tabs?

I am creating cookie using java script.

推荐答案

为什么不重用第二个标签[*]中的同一个交易ID,所以他们不能同时使用两个不同的ID登录(除非他们使用不同的浏览器)?


[*]检查ID。如果存在,则重用,如果不创建新的。
Why not reuse the same transaction id in the second tab[*], so they cannot login with two different IDs at the same time (unless they use a different browser)?

[*]check for the ID. If exists, reuse, if not create new one.


您是否可以将一些会话标识符编码到URL中,以便不同的选项卡环境具有不同的URL。


根据页面的生命周期,您可以使用时间戳,然后在页面被备份时进行alsocheck。
Could you encode some session identifier into the URL, so that different tab environments have different URLs.

Depending on the lifecycle of the page you could use a timestamp and then alsocheck if the page had been "backed".


@acoder


实际上,问题是用户来到页面选择产品然后转到付款页面。现在支付页面显示他500卢比。用户打开新标签购买价值1000卢比的产品。


现在我将交易ID存储在一个cookie中。所以第一个cookie被覆盖了。在这种情况下,只有一个选项卡有效,因此他可以支付Rs​​。 1000,支付确认cookie被删除后,之前金额(500卢比)的交易消失了。


在很多情况下,用户会在第一个标签页中转到付款页面支付500卢比。 (页面没有刷新,所以它仍然显示500卢比),但一个cookie说它的1000卢比。交易并发送给银行。


这意味着用户提交了Rs。 500和支付卢比。而是1000。
@acoder
Actually, the problem is user comes to the page select product and then goes to the payment page. Now payment page is showing him 500 Rs. User opens new tab purchase a product costing 1000 Rs.

Now I am storing transaction id in a single cookie. So first cookie got overridden. In this case only one tab is valid, so he can pay for Rs. 1000 and after a payment confirmation cookie is deleted, so the transaction for the previous amount (Rs. 500) is gone away.

In many cases users go to payment page in first tab to pay 500 Rs. (Page is not refreshed so it still shows Rs. 500) but a cookie says its 1000 Rs. Transaction and sends that much to bank.

That means user submitted Rs. 500 and paid Rs. 1000 instead.


这篇关于创建浏览器选项卡特定cookie的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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