Hi all,
Logout all sessions based on current user id and clear django sessions table based on user id. It is logging off all sessions.
```
# Logout all devices in account security page.
def logoff_all(request):
try:
# Filtering all session objects.
session_query = Session.objects.all()
# Iterating session_query and fetching session key.
for s in session_query:
# Decoding session key and getting id from that.
var_id = s.get_decoded().get('id')
# Converting string to int data type.
var_id_user = int(var_id)
# Id from decode and logged in session id is same then
# delete that session key from Session table from database.
if var_id_user == request.session.get('id'):
s.delete()
messages.success(request, "All sessions are logged off successfully.")
return HttpResponseRedirect("/home")
except Exception as e:
logging.error(e)
print(e)
return HttpResponseRedirect("/home")
```
How to solve this error after logout all devices Please
Thanks
~Salima