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

fix(setCookie): allow cookies with the same name but different options #606

Merged
merged 3 commits into from
Jan 12, 2024

Conversation

unite4
Copy link
Contributor

@unite4 unite4 commented Jan 5, 2024

πŸ”— Linked issue

#598

❓ Type of change

  • πŸ“– Documentation (updates to the documentation, readme, or JSdoc annotations)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

Resolves #598

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@pi0 pi0 changed the title fix(cookie): fix setCookie to respect serializeOptions fix(serializeOptions): allow cookies with the same name but different serializeOptions Jan 12, 2024
@pi0 pi0 changed the title fix(serializeOptions): allow cookies with the same name but different serializeOptions fix(setCookie): allow cookies with the same name but different serializeOptions Jan 12, 2024
Copy link
Member

@pi0 pi0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@pi0 pi0 changed the title fix(setCookie): allow cookies with the same name but different serializeOptions fix(setCookie): allow cookies with the same name but different options Jan 12, 2024
Copy link

codecov bot commented Jan 12, 2024

Codecov Report

All modified and coverable lines are covered by tests βœ…

Comparison is base (ae91fc8) 74.65% compared to head (337b03f) 74.67%.
Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #606      +/-   ##
==========================================
+ Coverage   74.65%   74.67%   +0.01%     
==========================================
  Files          47       47              
  Lines        4246     4249       +3     
  Branches      574      571       -3     
==========================================
+ Hits         3170     3173       +3     
  Misses       1061     1061              
  Partials       15       15              

β˜” View full report in Codecov by Sentry.
πŸ“’ Have feedback on the report? Share it here.

@pi0 pi0 merged commit 845eeca into unjs:main Jan 12, 2024
6 checks passed
@tobiasdiez
Copy link
Contributor

@unite4 @pi0 I'm a bit confused by the semantics of setCookie now. If I call it twice with the same name but different values, I get now two cookies instead of only one with the latest data. This feels counterintuitive. I encountered this in the context of the built-in session functionality. If you call updateSession you get two session cookies: an empty one and one with the updated data.

@frenzzy
Copy link
Contributor

frenzzy commented May 16, 2024

Currently, it is not possible to set custom session data for the first request:

const session = await useSession(...) // Adds set-cookie with empty data
session.update(...)                   // Adds set-cookie with custom data

The response returns two identical set-cookie headers, but it seems the browser uses only the first one.

Related: #705

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Overwriting headers Set-Cookie
4 participants