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
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters