# Keep sessions after logout

**URL:** <https://forum.djangoproject.com/t/keep-sessions-after-logout/34491>\
**Category:** Using Django\
**Created:** [September 4, 2024, 2:12pm UTC](https://forum.djangoproject.com/t/keep-sessions-after-logout/34491 "2024-09-04T14:12:52Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ArianN8610](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/ariann8610/32/23073_2.png) [@ArianN8610](https://forum.djangoproject.com/u/ArianN8610)\
**Post date:** [September 4, 2024, 2:12pm UTC](https://forum.djangoproject.com/t/keep-sessions-after-logout/34491/1 "2024-09-04T14:12:52Z")

</div>

I was trying to create a session through which I can determine the number of views of a post. So that only one visit was saved for each user and through this session I would know whether the user has already seen this post or not so that I don’t register a new view. But after the user logs out, the session is deleted and if the user login and sees the post again, a new view is registered. I know that it is possible to save the session after logout so that it is not deleted, but I can’t do it for this. Can I make the session not be deleted after logout or closing the site window or any other incident and its expiration period is 1 month?

---

<div class="post-metadata">

**Author:** ![lja0207](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/lja0207/32/23710_2.png) [@lja0207](https://forum.djangoproject.com/u/lja0207)\
**Post date:** [September 4, 2024, 2:51pm UTC](https://forum.djangoproject.com/t/keep-sessions-after-logout/34491/2 "2024-09-04T14:51:14Z")

</div>

lja0207@ 로그아웃후세션유지

> [@Keep sessions after logout](https://forum.djangoproject.com/t/keep-sessions-after-logout/34491):
>
> I was trying to create a session through which I can determine the number of views of a post. So that only one visit was saved for each user and through this session I would know whether the user has already seen this post or not so that I don’t register a new view. But after the user logs out, the session is deleted and if the user login and sees the post again, a new view is registered. I know that it is possible to save the session after logout so that it is not deleted, but I can’t do it for…

---

<div class="post-metadata">

**Author:** ![ArianN8610](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/ariann8610/32/23073_2.png) [@ArianN8610](https://forum.djangoproject.com/u/ArianN8610)\
**Post date:** [September 4, 2024, 3:02pm UTC](https://forum.djangoproject.com/t/keep-sessions-after-logout/34491/3 "2024-09-04T15:02:03Z")

</div>

What does this mean? Can you please type in English?

---

<div class="post-metadata">

**Author:** ![white-seolpyo](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/white-seolpyo/32/22386_2.png) [@white-seolpyo](https://forum.djangoproject.com/u/white-seolpyo)\
**Post date:** [September 5, 2024, 12:20am UTC](https://forum.djangoproject.com/t/keep-sessions-after-logout/34491/4 "2024-09-05T00:20:19Z")

</div>

Django performs a session flush upon logout, and what you want is a structural change to Django.  
It is recommended to measure the number of views in a different way or to redirect to a fixed page when logging out.

> <https://github.com/django/django/blob/main/django/contrib/auth/ __init__.py#L160>
