creating browser tab specific cookie

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • udaypawar
    New Member
    • Feb 2007
    • 29

    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.
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    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.

    Comment

    • DMsy2
      New Member
      • Dec 2009
      • 15

      #3
      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".

      Comment

      • udaypawar
        New Member
        • Feb 2007
        • 29

        #4
        Originally posted by acoder
        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.
        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.

        Comment

        • udaypawar
          New Member
          • Feb 2007
          • 29

          #5
          Originally posted by DMsy2
          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".
          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.

          Comment

          • sorokin88
            New Member
            • Dec 2009
            • 3

            #6
            I think you can store you data in the "window.nam e" 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.

            Comment

            • Dormilich
              Recognized Expert Expert
              • Aug 2008
              • 8694

              #7
              I think you can store you data in the "window.nam e" variable.
              in fact, every globally defined variable can do that.

              Comment

              • sorokin88
                New Member
                • Dec 2009
                • 3

                #8
                Dormilich, I don't think every globally defined variable can survive after you click a link on the site to load another page...

                Comment

                • Dormilich
                  Recognized Expert Expert
                  • Aug 2008
                  • 8694

                  #9
                  well, I doubt that window.name, resp. its content will.

                  Comment

                  • sorokin88
                    New Member
                    • Dec 2009
                    • 3

                    #10
                    It is easier to check it out than to doubt.

                    Comment

                    • acoder
                      Recognized Expert MVP
                      • Nov 2006
                      • 16032

                      #11
                      Originally posted by udaypawar
                      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.

                      Comment

                      • udaypawar
                        New Member
                        • Feb 2007
                        • 29

                        #12
                        Originally posted by sorokin88
                        It is easier to check it out than to doubt.
                        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.

                        Comment

                        • udaypawar
                          New Member
                          • Feb 2007
                          • 29

                          #13
                          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).

                          Comment

                          Working...