I am using Django.
How can i kick off a user who has logged-in?
or
How can i get the user's session and kill it?
If you can access the shell, then:
$ ./manage.py shell
In [1]: from django.contrib.sessions.models import Session
In [2]: for s in Session.objects.all():
...: data = s.get_decoded()
...: if data.get('_auth_user_id', None) == YOUR_USER_ID:
...: s.delete()
...:
...:
Replace YOUR_USER_ID
with the ID of a user to be kicked.
The key '_auth_user_id'
may differ from version to version, I suppose, but that worked for me. To check if you have the same, just print out some of s.get_decoded()
and look at the output.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With