I now have a somewhat different issue with session cookies.
1. I see that session['_id'] is created when a page on the site is
first encountered. Are '_creation_time' and 'accessed_time' supposed
to be created automatically? Or should those two fields be set in my
code?
2. The code below is in the base controller. A new session cookie is
produced (and new '_id' field) each time the same page is encountered:
if 'cre_dt' not in session_cookies:
session_cookies['cre_dt'] = datetime.now()
session_cookies['acc_dt'] = datetime.now()
session_cookies.save()
Can someone explain how Pylons handles session cookies and why the
session
Thanks.
Edgar
On Apr 7, 9:03 pm, edgarsmolow <[email protected]> wrote:
> I probably wanted this instead:
>
> ## set
> response.set_cookie('sitelang', 'uk', expires=3600) # Pylons 0.9.6
> syntax.
> response.set_cookie('sitelang', 'uk', max_age=3600) # Pylons 0.9.7
> syntax.
>
> ## get
> lang = request.cookies['sitelang']
>
> from
> here:http://wiki.pylonshq.com/display/pylonscookbook/Setting+cookies+and+r...
>
> Edgar
>
> On Apr 7, 1:52 pm, Thorsten Lockert <[email protected]> wrote:
>
> > On Apr 7, 2009, at 10:36 , Ben Bangert wrote:
>
> > > On Apr 7, 2009, at 5:52 AM, edgarsmolow wrote:
>
> > >>http://pylonshq.com/docs/en/0.9.7/sessions/#id2
>
> > >> but did not see a reference to these fields (you mentioned):
>
> > >>session['_id']
> > >>session['_accessed_time']
> > >>session['_creation_time']
>
> > >> I suppose I still don't understand the problem. If thecookie
> > >> exists,
> > >> when the browser is first directed to a URL, why can Beaker (or
> > >> whichever component is involved) read thecookie? If it had read the
> > >>cookie,session['some_var'] would be available.
>
> > > I'm not sure I understand what you're talking about either. The code
> > > sample you originally included could be translated like so:
>
> > > If there's acookiealready present:
> > > do something with it
> > > otherwise, when nocookieis around:
> > > do something else
>
> > > On the first visit to the web page, of course there isn't acookie
> > > YET, its the first visit after all. So the second if statement runs.
> > > On the second visit, since they've been there before, there's a
> > >cookiepresent, so the first if statement runs. This seems obvious
> > > enough, I'm not sure where the confusion is?
>
> > I think perhaps what he is expecting is a persistentcookie-- which
> > is not what sessions andsessioncookies are all about?
>
> > Thorsten
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"pylons-discuss" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---