Metadata-Version: 2.4
Name: django-session-refresh
Version: 0.1.0
Summary: A simple Django middleware to refresh user sessions periodically to prevent timeout during active use
Author-email: Anderson Lima <amilnosredna@gmail.com>
Project-URL: Homepage, https://github.com/amilnosredna/django-session-refresh
Keywords: django,session,refresh
Classifier: Framework :: Django :: 5
Classifier: Programming Language :: Python :: 3
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: django>=5.0
Dynamic: license-file

# django-session-refresh
A simple Django middleware to refresh user sessions periodically (24h by default) to prevent timeout during user activity.

This middleware updates a timestamp in the session data at specified intervals,
effectively extending the session's lifetime as long as the user is active.

## Installation
1. Run `pip install django-session-refresh`
2. Add `session_refresh.middleware.SessionRefreshMiddleware` settings.py ass bellow

```python
MIDDLEWARE = [
    ...
    'django.contrib.sessions.middleware.SessionMiddleware',  # Django default SessionMiddleware
    'session_refresh.middleware.SessionRefreshMiddleware',   # django-session-refresh
    ...
]
```

## Configuration (optional)
The settings bellow are optional and if not defined in settings.py the default values will be used.

```python
# The interval in seconds to refresh the session
SESSION_REFRESH_INTERVAL = 86400  # 24 hours
```
```python
# The name of the session key to store the last refresh timestamp
SESSION_REFRESH_KEY = 'last_session_refresh'
```
```python
# Skips session refresh for admin users
SESSION_REFRESH_SKIP_ADMIN_USERS = True
```
```python
# Skips session refresh for static and media file requests
SESSION_REFRESH_SKIP_STATIC_AND_MEDIA = True
```
```python
# Skips session refresh for unauthenticated users
SESSION_REFRESH_SKIP_UNAUTHENTICATED_USERS = True
```
