On Friday, June 7, 2013 2:03:14 PM UTC-4, Cliff Kachinske wrote:

> You can learn a lot about what's inside the session by adding 
> {{=BEAUTIFY(session)}} to the bottom of your main template.  As a rule of 
> thumb, anything that can be pickled can go into the session and it does 
> persist from request to request.
>
>
Cliff, 
Agreed. you can also just print these variables out in a controller method 
but that definitely works too! I think my confusion came from the naming.. 
one might very easily assume that current.session.id would be the current 
session's id (for instance). also, session_id only exists on the response 
object, not the request which is a bit confusing. 

Either way, it appears that Request, Response and Session are all just sort 
of variable dumping grounds of thread local storage. None of these classes 
seem to give me a way to callback (and delete my object) when the session 
itself has been finished.
 

> If anyone new to this stuff reads this post, you only do this on your 
> workstation system.
>
> You can also get tripped up by running two instances of your browser, 
> because the session remains alive even if you kill the instance where 
> you're doing your work.  This is an easy thing to do if you use an OS that 
> supports multiple workspaces.
>
>
 

> On Friday, June 7, 2013 11:28:48 AM UTC-4, Matt wrote:
>>
>> On Friday, June 7, 2013 9:53:42 AM UTC-4, Anthony wrote:
>>
>>> current.session is just the session object, which is in the web2py 
>>> global environment -- it contains the user's session for the current 
>>> request. The session itself does not include its own ID. If you want the 
>>> session ID, it is in response.session_id (also, 
>>> current.response.session_id). For file based sessions, the filename is in 
>>> response.session_filename.
>>>
>>> Also, the session cookie name is in response.session_id_name, so to get 
>>> the session cookie, do request.cookies[response.session_id_name].
>>>
>>>
>> Anthony,
>> Thanks for the clarification. What I'm really trying to do is to persist 
>> an object for a given session (a local unix domain socket to an rpc 
>> interface), but there doesn't seem to be any easy way to do this. 
>> Specifically, there doesn't seem to be a way for me to determine when a 
>> session has been closed/deleted in order to clean up the socket. Do you 
>> know of any way to do this? 
>>
>> Matt
>>  
>>
>>> Anthony
>>>
>>> On Tuesday, June 4, 2013 8:35:06 AM UTC-4, Matt wrote:
>>>>
>>>> Hi,
>>>> In one of my modules I'm trying to create a local socket connection 
>>>> that persists across a single session (one socket per one user logged into 
>>>> the system from a given browser), and thought that current.session would 
>>>> give me the info I needed. Specifically, we use a lot of REST calls in our 
>>>> frontend code to populate data for certain elements on the screen and this 
>>>> creates a new session hash for the current.session each time, but the 
>>>> actual session is the same. The only way I've been able to get a key that 
>>>> identifies the session is to run: 
>>>>
>>>>     cookies = current.request["cookies"]
>>>>     session = cookies["session_id_<appname>"].value
>>>>
>>>> Shouldn't some identifier (or even this cookie itself) be available in 
>>>> current.session? Perhaps I misunderstand the point of current.session.
>>>>
>>>> Matt
>>>>
>>>>

-- 

--- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to