Sanic-CookieSession implements a client side only, cookie-based session to be used with Sanic. Similar to the built-in session in Flask.
Quick Start
Installation
pip install Sanic-CookieSession
How to use it
from sanic import Sanic, response
import sanic_cookiesession
app = Sanic(__name__)
app.config['SESSION_COOKIE_SECRET_KEY'] = 'abcd'
sanic_cookiesession.setup(app)
@app.route('/')
def index(request):
session = request.ctx.session
session.setdefault('c', 0)
session['c'] += 1
return response.text(session['c'])
if __name__ == '__main__':
app.run(debug=True)
That’s it.
For more details, please see documentation.
License
BSD New, see LICENSE for details.
Links
Metadata
Release files for Sanic-CookieSession 0.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| sanic_cookiesession-0.3.1.tar.gz | 4.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| sanic_cookiesession-0.3.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 8.6 kB