Python / Django warn that your session is going to expire

1

I have a cookie that has been defined:

SESSION_COOKIE_AGE = 3600

And I would like to warn the user when it will expire.

What is the best way?

    
asked by Didina Deen 15.11.2016 в 10:07
source

1 answer

1

You can extract the expiration date of the session from the template with:

{{ request.session.get_expiry_date }}

You only need a little bit of js to show the warning to the user when the date approaches.

But you can always use AJAX and create a view where you can check with js. In the view you would do something similar:

caducidad = request.session.get_expiry_date()
    
answered by 28.12.2016 в 00:39