Logout time

52 views
Skip to first unread message

Prashanth Patelc

unread,
Jul 28, 2023, 10:35:38 AM7/28/23
to django...@googlegroups.com
Hi all,

How to get logout time based on login time in python?

I'm storing hour in one column
Eg ; hour
        8
Based on 8 Calculate logout time

My login time 10:00:00

I need 6: 00:00 (based 8)

Madhusudhan Reddy

unread,
Jul 28, 2023, 10:39:37 AM7/28/23
to django...@googlegroups.com
Please describe the problem properly bro.

we are not understanding




--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAMCU6Cpe32Pcs5PAmbx8LDcJzqqPwuhJVzrz%2B%3D67-tEMBychOw%40mail.gmail.com.


--

Annadatha Rao

unread,
Jul 28, 2023, 10:43:04 AM7/28/23
to django...@googlegroups.com
look for session : if session expires you have to log in again.

It is the same for all apps irrespective of python.

Thank you,
Annadatha.

Madhusudhan Reddy

unread,
Jul 28, 2023, 10:46:33 AM7/28/23
to django...@googlegroups.com
To get Logout time based on login time,

login time = some thing

logout time = login time + 8 hours

use datetime timedelta module in python, 

>>> CODE <<<
from datetime import datetime, timedelta
login_time = datetime.now()
logout_time = login_time + timedelta(hours=8)
>>> CODE <<<









On Fri, 28 Jul 2023 at 20:05, Prashanth Patelc <prashan...@gmail.com> wrote:
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAMCU6Cpe32Pcs5PAmbx8LDcJzqqPwuhJVzrz%2B%3D67-tEMBychOw%40mail.gmail.com.


--
Best regards,
Madhusudhan


Madhusudhan Reddy

unread,
Jul 28, 2023, 10:49:50 AM7/28/23
to django...@googlegroups.com
for better understanding

Screenshot from 2023-07-28 20-18-37.png

Ruby

unread,
Jul 28, 2023, 1:04:49 PM7/28/23
to django...@googlegroups.com
I could barely understand what you meant, 
I believe you're looking for a way to set how to set a session cookie age, if that is the case, see SESSION_COOKIE_AGE 
If that is not the case, note that you also have `last_login` and `last_logout` object which is available to you when using `django.contrib.auth`

Reuben Sunday

Prashanth Patelc

unread,
Jul 31, 2023, 6:12:23 AM7/31/23
to django...@googlegroups.com
Thank you all.

 Thank you # madhusudan (I got on idea through you shared the code)

ivan harold

unread,
Aug 9, 2023, 10:05:43 AM8/9/23
to Django users
Maybe this will help, check out this code.

def login (): login_time = time.time() def logout (): logout_time = time.time() #To get the number of seconds the user spent on the platform, #subtract login_time from logout_time

Reply all
Reply to author
Forward
0 new messages