{"id":22281047,"url":"https://github.com/aio-libs/aiohttp-session","last_synced_at":"2025-05-16T04:04:31.204Z","repository":{"id":25872848,"uuid":"29313003","full_name":"aio-libs/aiohttp-session","owner":"aio-libs","description":"Web sessions for aiohttp.web","archived":false,"fork":false,"pushed_at":"2025-05-14T00:35:36.000Z","size":985,"stargazers_count":240,"open_issues_count":7,"forks_count":89,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-05-15T02:37:03.762Z","etag":null,"topics":["aiohttp","asyncio"],"latest_commit_sha":null,"homepage":"http://aiohttp-session.readthedocs.io/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aio-libs.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGES.txt","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2015-01-15T19:03:01.000Z","updated_at":"2025-05-10T11:29:47.000Z","dependencies_parsed_at":"2023-11-27T01:37:59.918Z","dependency_job_id":"b6272917-1624-4454-a6b5-0315cf6a4386","html_url":"https://github.com/aio-libs/aiohttp-session","commit_stats":{"total_commits":830,"total_committers":53,"mean_commits":"15.660377358490566","dds":0.6590361445783133,"last_synced_commit":"a081f66bfeafb6a0fa461868bce36b2274a7cadc"},"previous_names":["aio-libs/aiohttp_session"],"tags_count":34,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aio-libs%2Faiohttp-session","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aio-libs%2Faiohttp-session/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aio-libs%2Faiohttp-session/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aio-libs%2Faiohttp-session/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aio-libs","download_url":"https://codeload.github.com/aio-libs/aiohttp-session/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254464893,"owners_count":22075570,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aiohttp","asyncio"],"created_at":"2024-12-03T16:13:09.001Z","updated_at":"2025-05-16T04:04:31.186Z","avatar_url":"https://github.com/aio-libs.png","language":"Python","readme":"aiohttp_session\n===============\n.. image:: https://github.com/aio-libs/aiohttp-session/actions/workflows/ci.yaml/badge.svg?branch=master\n    :target: https://github.com/aio-libs/aiohttp-session/actions/workflows/ci.yaml\n.. image:: https://codecov.io/github/aio-libs/aiohttp-session/coverage.svg?branch=master\n    :target: https://codecov.io/github/aio-libs/aiohttp-session\n.. image:: https://readthedocs.org/projects/aiohttp-session/badge/?version=latest\n    :target: https://aiohttp-session.readthedocs.io/\n.. image:: https://img.shields.io/pypi/v/aiohttp-session.svg\n    :target: https://pypi.python.org/pypi/aiohttp-session\n\nThe library provides sessions for `aiohttp.web`__.\n\n.. _aiohttp_web: https://aiohttp.readthedocs.io/en/latest/web.html\n\n__ aiohttp_web_\n\nUsage\n-----\n\nThe library allows us to store user-specific data into a session object.\n\nThe session object has a dict-like interface (operations like\n``session[key] = value``, ``value = session[key]`` etc. are present).\n\n\nBefore processing the session in a web-handler, you have to register the\n*session middleware* in ``aiohttp.web.Application``.\n\nA trivial usage example:\n\n.. code:: python\n\n    import time\n    from cryptography import fernet\n    from aiohttp import web\n    from aiohttp_session import setup, get_session\n    from aiohttp_session.cookie_storage import EncryptedCookieStorage\n\n\n    async def handler(request):\n        session = await get_session(request)\n        last_visit = session['last_visit'] if 'last_visit' in session else None\n        session['last_visit'] = time.time()\n        text = 'Last visited: {}'.format(last_visit)\n        return web.Response(text=text)\n\n\n    def make_app():\n        app = web.Application()\n        fernet_key = fernet.Fernet.generate_key()\n        f = fernet.Fernet(fernet_key)\n        setup(app, EncryptedCookieStorage(f))\n        app.router.add_get('/', handler)\n        return app\n\n\n    web.run_app(make_app())\n\n\nAll storages use an HTTP Cookie named ``AIOHTTP_SESSION`` for storing\ndata. This can be modified by passing the keyword argument ``cookie_name`` to\nthe storage class of your choice.\n\nAvailable session storages are:\n\n* ``aiohttp_session.SimpleCookieStorage()`` -- keeps session data as a\n  plain JSON string in the cookie body. Use the storage only for testing\n  purposes, it's very non-secure.\n\n* ``aiohttp_session.cookie_storage.EncryptedCookieStorage(secret_key)``\n  -- stores the session data into a cookie as ``SimpleCookieStorage`` but\n  encodes it via AES cipher. ``secrect_key`` is a ``bytes`` key for AES\n  encryption/decryption, the length should be 32 bytes.\n\n  Requires ``cryptography`` library::\n\n      $ pip install aiohttp_session[secure]\n\n* ``aiohttp_session.redis_storage.RedisStorage(redis_pool)`` -- stores\n  JSON encoded data in *redis*, keeping only the redis key (a random UUID) in\n  the cookie. ``redis_pool`` is a ``redis`` object, created by\n  ``await aioredis.from_url(...)`` call.\n\n      $ pip install aiohttp_session[aioredis]\n\n\nDeveloping\n----------\n\nInstall for local development::\n\n    $ make setup\n\nRun linters::\n\n    $ make lint\n\nRun tests::\n\n    $ make test\n\n\nThird party extensions\n----------------------\n\n* `aiohttp_session_mongo\n  \u003chttps://github.com/alexpantyukhin/aiohttp-session-mongo\u003e`_\n\n* `aiohttp_session_dynamodb\n  \u003chttps://github.com/alexpantyukhin/aiohttp-session-dynamodb\u003e`_\n\n\nLicense\n-------\n\n``aiohttp_session`` is offered under the Apache 2 license.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faio-libs%2Faiohttp-session","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faio-libs%2Faiohttp-session","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faio-libs%2Faiohttp-session/lists"}