Search code examples
pythonsessionsession-cookiespyramid

How do I persist session data for logins using pyramid_redis_session backend?


I'm using pyramid_redis_session as the backend session_factory. I'm not sure how to go about persisting session data during a login.

As per the pyramid documentation, its simply:

request.session['sid'] = hashedvalue

However, there is also the remember() function for logins. Is remember() to be used for logins and, and the above way to be used for other session data?


Solution

  • The session and the authentication policy are two separate systems. If you want the policy to know that the user is logged in you should use remember to inform it of that fact otherwise you will have the userid in the session but the authentication policy will not know - it typically has its own way of storing who the logged in user is.