I think the idea is you would not use the web2py server-side session but 
would instead handle things on the browser side.

An alternative would be to generate some kind of unique key for each 
page/tab to use as a namespace within the server-side session, and then 
either put that key in the URL (as an arg or in the query string), or 
handle page updates exclusively via Ajax and pass the key with each Ajax 
request (of course, when making post requests, you can pass the key via the 
posted data, but that doesn't help for non-post requests).

Also, note that the session is pickled automatically, so there is no need 
to pickle a dictionary before adding it to the session.

Anthony

On Friday, February 19, 2016 at 8:20:14 AM UTC-5, Jim S wrote:
>
> Thanks for the reply.  However, I'm unclear on how I might use it 
> effectively.
>
> My scenario in my app:
>
> I have a python object that I pass around to different pages.  At the end 
> of each of my controller methods I do the following:
>
> wo = Workorder(auth.user.id, workorder_id)
>
>
> #  save to the session
> session.workorder = cPickle.dumps(wo.to_dict())
>
>
> Then, at the beginning of each controller method I do:
>
> wo = Workorder(auth.user.id)
> wo.from_dict(cPickle.loads(session.workorder))
>
>
> So, with my limited javascript knowledge, I don't see how I'd be able to 
> convert this to sessionstorage.  And actually, I don't know if what I'm 
> doing with pickling/unpickling dicts is a smart thing to do.  If anyone has 
> any pointers/comments, I'd appreciate it.  However, it seems as though I 
> may need to rethink my strategy.
>
> Thanks for taking a look.
>
> -Jim
>
>
> On Friday, February 19, 2016 at 2:45:05 AM UTC-6, Niphlod wrote:
>>
>> every browser considers tabs as belonging to the same session in regards 
>> to cookies. there's no way to separate those using web2py code.
>> you can leverage sessionstorage in javascript that keeps values alive - 
>> and compartimentalized - to a single living tab.
>>
>> On Friday, February 19, 2016 at 4:56:21 AM UTC+1, Jim S wrote:
>>>
>>> Hi
>>>
>>> Is there a way to keep independent session variables between two open 
>>> browser tabs?
>>>
>>> Example
>>>
>>> 1.  write a session variable in tab 2
>>> 2.  switch to tab 1 and execute the same page setting the session 
>>> variable to a different value
>>> 3.  go back to tab 2 and request page that reads the session variable 
>>> and gets the value set from tab 1
>>>
>>> Is there any way to force each tab to have it's own session variables?
>>>
>>> -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 the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to