getting duplicate session storage in sugacrm

Hello Team,

I'm creating a plugin for a custom requirement, and for this, I need unique session storage(let's say tabID) on each tab. but session storage is behaving very strange with SugarCRM while in normal Html is it behaving correctly.

For example, SugarCRM is also using  a session storage variable 'pendo_tabId'. I checked this variable in two case

  1. When I open a new tab by clicking right click and open link in a new tab, and on the new tab when I'm checking in browser console/application/session storage, pendo_tabId is showing a unique value which is different from the previous tab.
  2. But when I open a new tab by clicking ctrl+click on a link, and a new tab is opened. But this time, in-browser console/application/session storage, pendo_tabId is showing the same value which is the same as the previous tab, it is not showing unique value.

While in normal HTML, it is behaving correctly. Please have a look at this and please tell me why it is not showing unique session storage on above both cases and how can I use unique session storage on different-2 sugar tabs.

Thanks,

Rishabh

  • Have you tried generating your own session-id? Is that behaving the same?

    Regards,

    Rolustech Support: support@rolustech.com 

  • Thanks Husaain for your reply.
    Yes, I generated my own session storage ID 'activeTabID' and it is behaving the same.

  • Hi

    Session storage doesn't exactly work "per tab", and sometimes works differently for different browsers. It depends on the top-level browsing context, which is dependent on the page where you originate the tab from. For example, the documentation from MDN - https://developer.mozilla.org/en-US/docs/Web/API/Window/sessionStorage states that:

    • Opening a page in a new tab or window creates a new session with the value of the top-level browsing context, which differs from how session cookies work.

    For example, lets say I have these two basic HTML files:

    Page 1:

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    <html>
    <body>
    Hello from Page 1
    <a href=test2.html target="_blank">Open Page 2</a>
    <div id="data"></div>
    <script type="text/javascript">
    sessionStorage.setItem("page1", "true");
    document.getElementById("data").innerHTML = JSON.stringify(sessionStorage);
    </script>
    </body>
    </html>
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    Page 2:

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    <html>
    <body>
    Hello from Page 2
    <div id="data"></div>
    <script type="text/javascript">
    sessionStorage.setItem("page2", "true");
    document.getElementById("data").innerHTML = JSON.stringify(sessionStorage);
    </script>
    </body>
    </html>
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    If you open Page 1 in the browser, it has a link to open page 2, which has target="_blank". When you click the link in chrome, it shows both page 1's session storage and page 2's storage as well. But - it works differently in firefox (v80) and it doesn't show page 1's info in page 2.

    If you really need unique session storage per tab, you can try the hack suggested in this stackoverflow thread - by using window.name

    https://stackoverflow.com/questions/24382266/sessionstorage-is-not-empty-when-link-opened-in-new-tab-in-internet-explorer

  • Thank you Neeraja,

    I checked the above StackOverflow link, it seems that it can solve my problem, I'm going to implement this.