Access the browser window.sessionStorage in my controller

329 views
Skip to first unread message

Jim S

unread,
Jun 7, 2016, 1:08:35 PM6/7/16
to web2py-users
I'm not that well-versed in the workings of a browser.  I'm wondering if anyone knows how I could, in my controller, access the window.sessionStorage key/value pairs set in my browser tab.  What I'm trying to do is to be able to pass objects from one web page to another.  This works fine until the user has multiple tabs/windows open and then the values I'm passing are not unique to the window/tab that I'm running on.  I'm wondering if there is a way for me to access the window.sessionStorage because I understand they are unique for each tab/window open in the browser.

Anyone have any experience with this?

-Jim

Niphlod

unread,
Jun 7, 2016, 4:20:00 PM6/7/16
to web...@googlegroups.com
the web is full of replies to your question

tl;dr: sessionstorage is only valid in the current tab. to persist client-side accross tabs, you need to leverage localstorage.

Anthony

unread,
Jun 7, 2016, 4:31:18 PM6/7/16
to web2py-users
Not exactly sure what you're asking. Of course, the server has no direct access to anything in the browser unless the browser sends it, so I suppose you could make an Ajax request to send whatever data you want to the server.

Anthony

Jim Steil

unread,
Jun 7, 2016, 4:45:30 PM6/7/16
to web...@googlegroups.com
Thanks Anthony, that was what I expected.

What I'm trying to accomplish is to be able to pass variables from page to page using the session variable in web2py.  This doesn't work if you have more than one window/tab open in the same browser with each tab open to the same series of pages.

-Jim

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/GnnDORlorWs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages