List Info

Thread: How to vanish session at end of browser session?




How to vanish session at end of browser session?
user name
2007-12-27 22:20:42
Hello, cp fans!

I am using cp's SessionTool . And I want to make session
'gone away'
when user close brower.

Although session is still in sever's storage, but browser
has remove
cookie `session_id', so server's session will be clear
sooner or
later.

So I search magic in code...I got in lib/sessions.py:
def init(storage_type='ram', path=None, path_header=None,
name='session_id',
         timeout=60, domain=None, secure=False,
clean_freq=5,
**kwargs):
...
    if timeout:
        cookie[name]['expires'] = http.HTTPDate(time.time()
+ (timeout
* 60))
...

If I uncomment this or del cookie[name]['expires'], it
rocks!

But i have no idea to hack SessionTool to disable
cookie['session_id']
['expires']. So I just  uncomment the upper code snippet!

Any sugguests to using SessionTool will set me free for hack
cp's
library file...And I am using cp 3.02.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "cherrypy-users" group.
To post to this group, send email to cherrypy-usersgooglegroups.com
To unsubscribe from this group, send email to
cherrypy-users-unsubscribegooglegroups.com
For more options, visit this group at h
ttp://groups.google.com/group/cherrypy-users?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: How to vanish session at end of browser session?
country flaguser name
United States
2007-12-28 11:57:04
jaxiinofea wrote:
> Hello, cp fans!
>
> I am using cp's SessionTool . And I want to make
session 'gone away'
> when user close brower.
> ...
> So I search magic in code...I got in lib/sessions.py:
> def init(storage_type='ram', path=None,
path_header=None,
> name='session_id',
>          timeout=60, domain=None, secure=False,
clean_freq=5,
> **kwargs):
> ...
>     if timeout:
>         cookie[name]['expires'] =
http.HTTPDate(time.time() + (timeout
> * 60))
> ...
>
> If I uncomment this or del cookie[name]['expires'], it
rocks!
>   

Did you check the documentation?  In your config file, where
you set
    tools.sessions.on = True
just add
    tools.sessions.timeout = 0

-- 
Tim Roberts, timrprobo.com
Providenza & Boekelheide, Inc.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "cherrypy-users" group.
To post to this group, send email to cherrypy-usersgooglegroups.com
To unsubscribe from this group, send email to
cherrypy-users-unsubscribegooglegroups.com
For more options, visit this group at h
ttp://groups.google.com/group/cherrypy-users?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: How to vanish session at end of browser session?
user name
2008-01-02 00:49:32
Hi Tim,

If i add this(tools.sessions.timeout = 0) to config. The
Cookies will
be existed in brower sesion as i expected, but the sessions
in server
will be disabled at once(Session.timeout will be set to 0
too). This
can't work:(

I examine the sessions.py again.
def init(storage_type='ram', path=None, path_header=None,
name='session_id',
         timeout=60, domain=None, secure=False,
clean_freq=5,
**kwargs):

I see the cookie timeout equal to the session timeout. It's
need
another parameter `cookie_timeout' for me to let the session
 lost if
people close the browser for more security. And use
`cookie_timeout'
to set http expires:

    if cookie_timeout:
        cookie[name]['expires'] = http.HTTPDate(time.time()
+
(cookie_timeout* 60))

so I can config cp like this:
tools.sessions.on = True
tools.sessions.cookie_timeout = 0

On Dec 29 2007, 1:57 am, Tim Roberts <t...probo.com> wrote:
> jaxiinofea wrote:
> > Hello, cp fans!
>
> > I am using cp's SessionTool . And I want to make
session 'gone away'
> > when user close brower.
> > ...
> > So I search magic in code...I got in
lib/sessions.py:
> > def init(storage_type='ram', path=None,
path_header=None,
> > name='session_id',
> >          timeout=60, domain=None, secure=False,
clean_freq=5,
> > **kwargs):
> > ...
> >     if timeout:
> >         cookie[name]['expires'] =
http.HTTPDate(time.time() + (timeout
> > * 60))
> > ...
>
> > If I uncomment this or del
cookie[name]['expires'], it rocks!
>
> Did you check the documentation?  In your config file,
where you set
>     tools.sessions.on = True
> just add
>     tools.sessions.timeout = 0
>
> --
> Tim Roberts, t...probo.com
> Providenza & Boekelheide, Inc.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "cherrypy-users" group.
To post to this group, send email to cherrypy-usersgooglegroups.com
To unsubscribe from this group, send email to
cherrypy-users-unsubscribegooglegroups.com
For more options, visit this group at h
ttp://groups.google.com/group/cherrypy-users?hl=en
-~----------~----~----~----~------~----~------~--~---


[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )