473,396 Members | 1,998 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

creating browser tab specific 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.
Dec 6 '09 #1

✓ answered by sorokin88

I think you can store you data in the "window.name" variable. It is tab or window specific and stays the same as user moves from one page to another (until you change it using javascript).

If a user opens your site in a new tab or clicks a link to open target page in a new tab, the value won't be copied and will be empty there.

12 20531
acoder
16,027 Expert Mod 8TB
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.
Dec 6 '09 #2
DMsy2
15
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".
Dec 6 '09 #3
@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.
Dec 26 '09 #4
@DMsy2
I already thought of this, but the problem is I have to pass transaction id through URL. Furthermore, I am maintaining user friendly URL's, so not a good idea.

In addition, I am allowing users to navigate the entire website and come back for payment, so I have to keep track of this on all the pages (Even on static HTML pages).

Even It's very difficult to pass it using form post on all over the website.
Dec 26 '09 #5
I think you can store you data in the "window.name" variable. It is tab or window specific and stays the same as user moves from one page to another (until you change it using javascript).

If a user opens your site in a new tab or clicks a link to open target page in a new tab, the value won't be copied and will be empty there.
Dec 27 '09 #6
Dormilich
8,658 Expert Mod 8TB
I think you can store you data in the "window.name" variable.
in fact, every globally defined variable can do that.
Dec 27 '09 #7
Dormilich, I don't think every globally defined variable can survive after you click a link on the site to load another page...
Dec 27 '09 #8
Dormilich
8,658 Expert Mod 8TB
well, I doubt that window.name, resp. its content will.
Dec 27 '09 #9
It is easier to check it out than to doubt.
Dec 28 '09 #10
acoder
16,027 Expert Mod 8TB
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.
As I said, why not keep one cookie for a single user, so they can have two transactions stored in one cookie? If that's a problem, store the transactions with one ID, so for example, they go to payment (amount 500), then they open another tab. It will show 500 in their basket/shopping cart. If they now purchase another item for 1000, it will have two items and a total of 1500.
Dec 30 '09 #11
@sorokin88
I have a doubt, whether it is accessible in a child window (popup) or not, but seems to be a better idea will try this and will let you know on success.
Jan 1 '10 #12
I tried this in Firefox and its working fine. It won't work in case if the new window is opened with the attribute target="_blank" (considered as new window I guess).
Jan 1 '10 #13

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: collie | last post by:
Hi, I have an asp page where i created cookies-for admin and for user. The aspx page reads these cookies. Everything seems to work fine but now i have to create a new cookie if cookie has...
1
by: Chak | last post by:
How easy / difficult is it to create web reports using 'XML + XSLT' ? Any examples on the web ?
15
by: lawrence | last post by:
Is this the correct way to test for a method before I use it? createRange() is, I believe, an IE only method. function wrapSelectionInTag(selection, tag) { if (document.selection.createRange)...
0
by: clintonG | last post by:
Has anybody seem any documentation or tutorials that discuss browser specific Themes? // Example <%@ Page Language="C#" IE:Theme="IeTheme" Mozilla:Theme="MozillaTheme" %> <%= Clinton...
5
by: David Baker | last post by:
Hi all I am very new to ASP.Net. I am trying to create a sniffer for our program. We want our users to click our sniffer and hopefully the sniffer will check their computer against our...
3
by: Ben | last post by:
Hi, I'm sending out a session cookie. That is a cookie that has no expiration date. When I surf through the site, no problems, but if I close the browser and open it back up, the cookie is still...
1
by: quist | last post by:
Is there a way to specify browser specific themes in the web.config like you can in the page declaration of a content page? If you can't there and you can't in the master page, then you have to...
3
by: Smokey Grindle | last post by:
Is there any way in asp.net 2.0 to say if this specific browser views my site give them a CSS sheet that is specific for that browser? like IE6 get its own, FF get its own, IE7 gets the one FF...
13
by: BLKeller | last post by:
I'm having a problem with a site I'm working on which contains links to Reporting Services reports. The pages are written in HTML and classic ASP. The links to the reports are in the following...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.