I have installed django-redis-session via pip and add this settings to the settings.py file:SESSION_ENGINE = 'redis_sessions.session'When I go to the terminal and type:$ redis-cli monitorI can see there are changes when I log in and log out (using python-social-auth).My question is: How can I get the session (from redis) based on the user?If I call is_authenticated() User's function it works, but my DB's (PostgreSQL) Session table has 0 rows.Fianlly, is there any way to write the session key and data manually? I will need to use a complex PK for session based in two fields stored in redis.
I don't understand your question. Why would you expect any rows in Posgres? You've specifically set the session backend to redis.
DanielRoseman Yes, I don't expect rows in Postgres I was just saying that session has been succesfully stored in redis.
From request.session I can access to user, thanks.
If you need the logged in user, then use request.user - you shouldn't have to go via the session.
Thanks again, one more question: Do you know how can I write the session manually? I need to use a complex PK for sessions and I'd like to store this in redis.
I'm not sure what you mean by 'write the session manually'. You can store values in the session with request.session['key'] = 'value'. If you are trying to change the session key, then I'm not immediately sure how you would do that, and I don't think it's a good idea anyway. Session keys should not be guessable.
I will take a look. Thanks again!