semvec/pypi-packages huggingface dataset:
django-session-timeout-joinup 1.0.0
Middleware to expire sessions after specific amount of time
License: MIT


# django-session-timeout

Add timestamp to sessions to expire them independently

## Installation

```shell
pip install django-session-timeout-joinup
```

## Usage

Update your settings to add the SessionTimeoutMiddleware:

```python
MIDDLEWARE_CLASSES = [
    # ...
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django_session_timeout.middleware.SessionTimeoutMiddleware',
    # ...
]
```

And also add the ``SESSION_EXPIRE_MAXIMUM_SECONDS``:

```python
SESSION_EXPIRE_MAXIMUM_SECONDS = 28800  # 8 hours
```

By default, the session will expire X seconds since the user do login.

```python
SESSION_EXPIRE_SECONDS = 3600  # 1 hour
```

The session will expire X seconds after the start of the session or renew it.
To renew the session X seconds after expire, use the following setting:

```python
SESSION_EXPIRE_AFTER_LAST_ACTIVITY_GRACE_PERIOD = 1800  # 30 minutes
```

To redirect to a custom URL define the following setting:

```python
SESSION_TIMEOUT_REDIRECT = 'your_redirect_url_here/'
```