Dev environment sessions without Redis. Data expires automatically—no cleanup scripts.
You're prototyping an app that needs session storage. Setting up Redis or memcached feels like overkill for development.
Use WrenDB as a simple session store. Perfect for local dev and testing.
# Python Flask example
from flask import Flask, session, request
import requests
import uuid
app = Flask(__name__)
STASH_ID = "your-stash-id"
@app.route('/login', methods=['POST'])
def login():
user_id = request.form['user_id']
session_id = str(uuid.uuid4())
# Store session in WrenDB
requests.post(
f'https://wrendb.com/api/item/{STASH_ID}/session-{session_id}',
json={'user_id': user_id, 'logged_in_at': '2024-01-15T12:00:00Z'}
)
session['id'] = session_id
return 'Logged in!'
@app.route('/profile')
def profile():
session_id = session.get('id')
if not session_id:
return 'Not logged in', 401
# Get session from WrenDB
response = requests.get(
f'https://wrendb.com/api/item/{STASH_ID}/session-{session_id}'
)
if response.status_code == 404:
return 'Session expired', 401
user_data = response.json()
return f"Welcome user {user_data['user_id']}"