'Custom middleware to check active session, sesison.id for logging out users with inactivity and dynamic typing-django

I am building a django application and am presently working on the login system.

I want to implement following things:-

  1. Inactive users are redirected to a session out page after inactivity.
  2. If a user types in any url or pastes any url manually, he should be redirected to the session out page.

I have done something called custom Interceptor in Grails and read a bit about django middleware.

Could anyone guide in writing a custom middleware in django for the following purposes.

Regards



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source