The My Opera forums have been replaced with forums.opera.com. Please head over there to discuss Opera's products and features
See the new ForumsYou need to be logged in to post in the forums. If you do not have an account, please sign up first.
Need help with sessionStorage and localStorage
How do I even get started using session/local storage in an opera extension? I'm more interested in session storage, as I want my extension to keep a session-only history (basically the storage is GONE after opera is shut down and relaunched)Do HTML5 session storage tutorials work here?
sessionStorage, localStorage, and Opera's two special storage objects, scriptStorage and widget.preferences are all HTML5 storage objects, so if you've read any good tutorial on that, you already know how they work. Just be careful of the different contexts they apply to:
I haven't tried sessionStorage on the background script, but I assume it will be cleared when you disable the extension or close Opera. If you use something other than widget.preferences though, you'll have to send messages back and forth, since widget.preferences is the only one that is shared between the background script and injected script.
in background script in injected script
sessionStorage The background script only The tab the script is on
localStorage The background script only The web page the script is on
scriptStorage (doesn't exist) All instances of the injected script
widget.preferences Shared between background script and injected script (buggy on private tabs)
I haven't tried sessionStorage on the background script, but I assume it will be cleared when you disable the extension or close Opera. If you use something other than widget.preferences though, you'll have to send messages back and forth, since widget.preferences is the only one that is shared between the background script and injected script.
Opera 12.15 - Win 8 Pro x64 All my Opera tools -Tab Vault: Save tabs for later -AutoStack: tabs opened from a stack stay there
Thank you for sharing this info. There is one more possible context: popup window. Do you know how storage will work in popup context?
One more possibility to have session storage in background process is to store data in object. Functionality is almost the same as in sessionStorage, and data will be reset when Opera is closed.
One more possibility to have session storage in background process is to store data in object. Functionality is almost the same as in sessionStorage, and data will be reset when Opera is closed.
I'm not entirely sure about this, but I believe localStorage is shared between the background script and popup, no idea about sessionStorage, scriptStorage doesn't exist there, and widget.preferences is shared in all extension contexts.
Opera 12.15 - Win 8 Pro x64 All my Opera tools -Tab Vault: Save tabs for later -AutoStack: tabs opened from a stack stay there