4

I currently have a SaaS B2B product, I'd love to show for the sake of example, if it weren't behind a VPN. But the case is, Its built on top of Zend Framework it is using Zend's session handling. That said my users recently decided that with recent improvements to various ends of the UI that they want to use the Service across multiple tabs at once, which isn't exactly currently supported, but in the name of wanting to keep on improving. I have to meet demands. That said. With this one piece of the service I have been managing data with cookies, since the page can be reloaded, and the UI re-rendered respectively to match the reloaded UI (the reload is triggered by content in an iFrame, since we can't communicate parent child from within the frame.

However now that my users are insisting on doing the same action across multiple tabs trying to save time, this breaks the UI since the cookies are not in any way shape or form tagged with an ID, from which I wouldn't even know how to imply that since I can't necessarily track tabs. So With all this I figured i'd give localstorage a go. However I am still not sure how to handle a single user on multiple tabs to prevent UI data being used on different tabs, more so if the page gets refreshed at a given time which could maybe lose data in localstorage?

So what I am trying to figure out all in all. Is how to manage this single user across one or more tabs without one tabs data interfering with the other tabs data, since the actions and ui are all contained within the same domain. (Does this clarify anything better?)

chris
  • 36,115
  • 52
  • 143
  • 252
  • Question needs more clarity as to what expectations are for various window states. There are events associated with localStorage that may help you ... for example http://html5demos.com/storage-events – charlietfl Mar 02 '15 at 14:35
  • Like @Ewald Stiegler answered, sessionStorage would suit your situation better. – Martin Mar 02 '15 at 14:38

1 Answers1

16

Yes, you can use localStorage to store data for your web app. Also, have a look at sessionStorage which is window/tab specific and stores data per session.

Read more here:

HTML5 Web Storage

Scope of sessionStorage and localStorage

Community
  • 1
  • 1
Atomic Star
  • 5,427
  • 4
  • 39
  • 48
  • excellent Ill get reading on that right now. I altered my question heavily in hopes of defining the scope of the question better. Your answer seems to sum up what I am looking for overall. But one question, session or local storage. Will data be lost on a tabs reload? – chris Mar 02 '15 at 14:45
  • SessionStorage and localStorage data will not be lost when the tab is refreshed. However, if you close the tab, sessionStorage data will be lost. Data in localStorage will still be available on other tabs even if the tab is closed. – Atomic Star Mar 03 '15 at 10:02
  • Based on your edited answer I would use localStorage for user data that should be available across multiple tabs and sessionStorage for data that is specific to your current tab page – Atomic Star Mar 03 '15 at 10:08