Closed
Description
Expected Behaviour
When using the Cookie
class from aws_lambda_powertools.shared.cookies
the resulting Set-Cookie
header when passed to the Response
class will contain a cookie that has the attribute of Max-Age
.
Current Behaviour
The Cookie
class from aws_lambda_powertools.shared.cookies
says it follows the RFC of https://tools.ietf.org/html/rfc6265, however when passing in the max_age
argument, the final Set-Cookie
string that is produced is MaxAge
instead of Max-Age
resulting in the browser defaulting to session
length for the cookie expiration.
Code snippet
from aws_lambda_powertools.shared.cookies import Cookie
from aws_lambda_powertools.event_handler import Response
cookie = Cookie(name="Test", value="Test", max_age=60)
str(cookie)
Possible Solution
Within the aws_lambda_powertools.shared.cookies.py
add a -
to the max age section that performs serialisation.
Steps to Reproduce
Running the below code snippet will reproduce the issue.
from aws_lambda_powertools.shared.cookies import Cookie
from aws_lambda_powertools.event_handler import Response
cookie = Cookie(name="Test", value="Test", max_age=60)
str(cookie)
>>> 'Test=Test; MaxAge=60; Secure'
Powertools for AWS Lambda (Python) version
latest
AWS Lambda function runtime
3.12
Packaging format used
PyPi
Debugging logs
No response
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Shipped