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.

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.

Project details


Download files

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

Source Distribution

sanic_cookiesession-0.3.1.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

sanic_cookiesession-0.3.1-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

Details for the file sanic_cookiesession-0.3.1.tar.gz.

File metadata

  • Download URL: sanic_cookiesession-0.3.1.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.9.3 CPython/3.11.6

File hashes

Hashes for sanic_cookiesession-0.3.1.tar.gz
Algorithm Hash digest
SHA256 7e5a44c16c8541c9aadb57a616be692ecee57a137ac49a2cc6f61a09c90b0624
MD5 f701721695c72cf8eeb53f4593c367f8
BLAKE2b-256 0fd2a01227382bffa8f1e2d77f84a7d39b3fc63d1ac81780419f511a2f53f64d

See more details on using hashes here.

File details

Details for the file sanic_cookiesession-0.3.1-py3-none-any.whl.

File metadata

File hashes

Hashes for sanic_cookiesession-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7a40959bf2ea189e59221213ce7ec9b4e89f0943981912f7ee8b3ada5738eb0d
MD5 a886d8177f07af384e8611d525d54078
BLAKE2b-256 b5948e427ab0e09ef419511f3ef1499df22cf68f2cebd0c84d99fca0df5e3f86

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page