[albatross-users] SessionFileAppMixin has no session_age

Michael Barrett mike at daboyz.org
Wed Jan 29 19:36:31 EST 2003


Ok, I'm not sure if this is kosher, but I went ahead and edited the 
sessionfile.py to have the feature I wanted.  I've gone ahead and attached
a diff of what I did.  I think the way I did it won't break any other uses
of the classes I edited.  Anyways, have a look and let me know if you can
think of any problems with this.  Thanks Andrew for helping me pin down
where the 'problem' was.

###### Begin Diff
13a14
>     import time
28c29
<     def __init__(self):
---
>     def __init__(self, session_ttl=None):
30a32
>         self.__session_ttl = session_ttl
62a65,66
>         if self.__session_ttl:
>             c[self.app.ses_appid()]['expires'] = time.strftime('%a, %d-%b-%Y %H:%M:%S GMT',time.gmtime(time.time()+self.__session_ttl))
148c152
<     def __init__(self, app):
---
>     def __init__(self, app, session_ttl=None):
151c155
<         SessionFileContextMixin.__init__(self)
---
>         SessionFileContextMixin.__init__(self, session_ttl)

#### End DIFF
On Wed, Jan 29, 2003 at 09:52:18AM +1100, Andrew McNamara wrote:
> >I was actually looking for a way to make the sessions last longer.
> >Wouldn't it just be a matter of turning up the expire time on the cookie?
> >
> >I pretty much want to make it so that if someone logs into my site, and
> >clicks the 'remember me' button it does just that and lets them log in.
> >Say it keeps the session for about a week.
> 
> Ah! Currently we set no "Max-Age" on the cookie, so it lasts until the
> user closes the browser. So, yes, setting an explicit Max-Age would help
> in your application, and the SessionFile mixin in perfect, as the sessions
> are persistent (the SessionServer's sessions are stored in memory, so if
> the server is restarted, they are lost - this will be rectified one day,
> but should be considered a "feature" until them... 8-).
> 
> The problem is, we don't expose the cookie machinery to the application. If
> you look in sessionfile.py, SessionFileContextMixin, you'll see how we're
> setting the cookie. You could sub-class and replace load_session with a
> version that sets the max-age on the resulting cookie.
> 
> We need to put some thought into making the cookie available to the
> developer.
> 
> -- 
> Andrew McNamara, Senior Developer, Object Craft
> http://www.object-craft.com.au/
> _______________________________________________
> Albatross-users mailing list
> Albatross-users at object-craft.com.au
> https://www.object-craft.com.au/cgi-bin/mailman/listinfo/albatross-users

-- 
     ________________________________________________________________________
                Mike Barrett | "I used to read, now I go to raves."
             mike at daboyz.org | -- Random MUNI Rider, speaking
              www.daboyz.org |    to my friend Allison.
     ------------------------+-----------------------------------------------



More information about the Albatross-users mailing list