Skip to main content

Sanic-CookieSession - Simple Cookie-based Session for Sanic

Project description

Sanic-CookieSession implements a client side only, cookie-based session to be used with Sanic. Similar to the built-in session in Flask.

Warning

The session cookie is signed cryptographically to prevent modification, but the content is not encrypted, NEVER store information that need to be kept secret.

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['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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for Sanic-CookieSession, version 0.2.0
Filename, size File type Python version Upload date Hashes
Filename, size Sanic_CookieSession-0.2.0-py2.py3-none-any.whl (5.0 kB) File type Wheel Python version py2.py3 Upload date Hashes View
Filename, size Sanic-CookieSession-0.2.0.tar.gz (7.9 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page