Skip to content

Request.set_cookie(expires) requires a UTC datetime but doesn't document this #254

@dobesv

Description

@dobesv

Currently Response.set_cookie will accept a datetime instance to specify the time at which the cookie should expire.

However, this datetime instance is expected to be a utc datetime, for example datetime.utcnow() + timedelta(seconds=3600), not a local datetime like datetime.now() + timedelta(seconds=3600).

Also, the provided datetime instance must NOT be timezone-aware or you will get an error. For example passing datetime.utcnow(tz=pytz.utc) + timedelta(seconds=3600).

If callers are not aware of these requirements, their application might fail unexpectedly if the app moves between time zones.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions