Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cookies not able to be deleted by setting max-age to 0 #867

Closed
allen-chao opened this issue May 1, 2024 · 4 comments
Closed

Cookies not able to be deleted by setting max-age to 0 #867

allen-chao opened this issue May 1, 2024 · 4 comments
Assignees
Labels

Comments

@allen-chao
Copy link

To help us debug your issue fill in the basic information below using the options provided

Serverless Java Container version: com.amazonaws.serverless:aws-serverless-java-container-springboot3:2.0.0

Implementations: Spring Boot 3

Framework version: eg SpringBoot3 2.0.0

Frontend service: REST API / ALB

Deployment method: SAM

Scenario

When calling servletResponse.addCookie method with max-Age set to 0, cookies are not getting deleted.

Expected behavior

Max-Age 0 is a valid value for cookies to expire immediately and a common way to delete cookies.

Actual behavior

Cookies are being set to session cookies instead of getting deleted. Had to do a workaround to set max-Age to 1 and have it expire after 1 second.

Source code that causes this issue

Steps to reproduce

  1. Call servletResponse.addCookie(Cookie(name, value, 0, domain)) method
  2. Check cookies from application section in browser developer console.
  3. Cookies that are intended to be deleted will show as session cookies and not getting deleted

Full log output

I am running a project that cannot be shared on public github

@deki
Copy link
Collaborator

deki commented May 7, 2024

Thanks for the issue report. For stateless serverless web applications cookies are usually not being used but we can fix it anyway.

Are you willing to submit a PR to make the code more compliant with RFC 6265? Example implementation: https://github.com/apache/tomcat/blob/main/java/org/apache/tomcat/util/http/Rfc6265CookieProcessor.java#L106

@deki deki added the bug label May 7, 2024
@leekib
Copy link
Contributor

leekib commented Aug 19, 2024

@deki Would it be okay if I work on updating code to comply with RFC 6265 and submit a PR?

@deki
Copy link
Collaborator

deki commented Aug 19, 2024

@2012160085 absolutely, contributions are always welcome!

@deki
Copy link
Collaborator

deki commented Nov 27, 2024

Fixed as part of the 2.1.0 release.

@deki deki closed this as completed Nov 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants