PHP 8.2.30
Preview: cookies_identity.py Size: 887 B
/proc/thread-self/root/opt/cloudlinux/venv/lib/python3.11/site-packages/aiohttp_security/cookies_identity.py

"""Identity policy for storing info directly into HTTP cookie.

Use mostly for demonstration purposes, SessionIdentityPolicy is much
more handy.

"""

from .abc import AbstractIdentityPolicy


sentinel = object()


class CookiesIdentityPolicy(AbstractIdentityPolicy):

    def __init__(self):
        self._cookie_name = 'AIOHTTP_SECURITY'
        self._max_age = 30 * 24 * 3600

    async def identify(self, request):
        identity = request.cookies.get(self._cookie_name)
        return identity

    async def remember(self, request, response, identity, max_age=sentinel,
                       **kwargs):
        if max_age is sentinel:
            max_age = self._max_age
        response.set_cookie(self._cookie_name, identity,
                            max_age=max_age, **kwargs)

    async def forget(self, request, response):
        response.del_cookie(self._cookie_name)

Directory Contents

Dirs: 1 × Files: 6

Name Size Perms Modified Actions
- drwxr-xr-x 2026-02-06 08:01:08
Edit Download
1.45 KB lrw-r--r-- 2026-01-20 13:01:48
Edit Download
5.75 KB lrw-r--r-- 2026-01-20 13:01:48
Edit Download
887 B lrw-r--r-- 2026-01-20 13:01:48
Edit Download
1.18 KB lrw-r--r-- 2026-01-20 13:01:48
Edit Download
1.09 KB lrw-r--r-- 2026-01-20 13:01:48
Edit Download
791 B lrw-r--r-- 2026-01-20 13:01:48
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).