webapp2 sessions get_sessions (max_age) does not override default config

223 views
Skip to first unread message

ogterran

unread,
Oct 1, 2012, 4:17:01 AM10/1/12
to google-a...@googlegroups.com
I am using webapp2 sessions and I want to override my default max_age settings (None) by using the max_age parameters in get_sessions()

self.session_store = sessions.get_store(request=self.request)

self.session_store.get_session(max_age=1000000, backend='datastore')

The backend works here, as i see the session in the database, but max_age is still None, as when i view the cookie in the browser, it expires when the browsing session ends. 

How can i override the default max_age? 


Thanks

Jon

alex

unread,
Oct 1, 2012, 4:32:08 AM10/1/12
to google-a...@googlegroups.com
I believe you can do this by setting session_max_age config param.
See this for more details:
http://webapp-improved.appspot.com/_modules/webapp2_extras/sessions.html

Also, the webapp2 group is actually here:
https://groups.google.com/forum/#!forum/webapp2

-- alex
> --
> You received this message because you are subscribed to the Google Groups
> "Google App Engine" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/google-appengine/-/rdSeFu0wq4MJ.
> To post to this group, send email to google-a...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-appengi...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/google-appengine?hl=en.

ogterran

unread,
Oct 1, 2012, 4:36:53 AM10/1/12
to google-a...@googlegroups.com
I know i can set the max_age in the config. I did that. 
But i want to override the max_age value from config, by setting max_age in get_sessions.

Use case is this. I want by default max_age to be None.
But if the user clicks on the "Remember me" checkbox,  their session to last longer than the browser session. 

alex

unread,
Oct 1, 2012, 4:41:43 AM10/1/12
to google-a...@googlegroups.com
I think max_age param in get_session() is used to verify a session validity.

What you're after is probably webapp2_extras.auth.set_session(...,
remember=True)
See this: http://webapp-improved.appspot.com/_modules/webapp2_extras/auth.html#Auth.set_session

ps. Please do move this discussion to web...@googlegroups.com
> https://groups.google.com/d/msg/google-appengine/-/wJ17Xn4mQhoJ.

ogterran

unread,
Oct 1, 2012, 4:45:49 AM10/1/12
to google-a...@googlegroups.com
Ah, that makes more sense now. 
I'll take a look at auth.set_session and move this discussion to webapps2.

Thanks!
Reply all
Reply to author
Forward
0 new messages