开发者

Using beaker sessions for checking if user is authenticated in Pyramid

I'm creating a webapp using Pyramid with Beaker sessions.

I would like to store user id in request.session['user_id'] and some other info after successful signing in and then use it for checking if user already signed in:

if 'user_id' in request.session:
    # user signed in
else:
    # user not signed in or session is expi开发者_JAVA百科red

The question is: is it safe to rely on sessions or it will be better and/or safer to use Pyramid's authenticated_userid() with remember() and forget() from pyramid.security?


Use pyramid_beaker and the SessionAuthenticationPolicy, then use pyramid.authentication.authenticated_userid() to check if they're logged in or not. If it returns None, they're not.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜