use session #237
Unanswered
Ali-Nazarii
asked this question in
Q&A
use session
#237
Replies: 1 comment
-
Hey @Ali-Nazarii—this isn't directly supported, so the best option is probably going to be to use a callable def session_key(group, request):
key = request.session.get('some_key', None)
if key is None:
key = generate_key_somehow()
request.session['some_key'] = key
return key
@ratelimit(key=session_key)
def my_view(req):
pass You could use the session ID directly, but be aware that not all backends have a session ID and that it's not necessarily stable (actions like logging in or out might rotate the session key). |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello, how can I use the session as a key when the user has not logged in?
Beta Was this translation helpful? Give feedback.
All reactions