Skip to content

docs: clarify ResponseCookie Max-Age behavior according to RFC 6265 #35216

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,18 @@ private ResponseCookie(String name, @Nullable String value, Duration maxAge, @Nu


/**
* Return the cookie "Max-Age" attribute in seconds.
* <p>A positive value indicates when the cookie expires relative to the
* current time. A value of 0 means the cookie should expire immediately.
* A negative value means no "Max-Age" attribute in which case the cookie
* is removed when the browser is closed.
* Return the cookie "Max-Age" attribute.
* <p>
* <ul>
* <li>Positive value: the cookie expires after the specified duration (persistent cookie).</li>
* <li>Zero: the cookie expires immediately (deleted).</li>
* <li>Negative value: no "Max-Age" attribute is sent, and the cookie becomes a <b>session cookie</b>
* (removed when the browser is closed).</li>
* </ul>
*
* <p>See <a href="https://datatracker.ietf.org/doc/html/rfc6265#section-5.2.2">RFC 6265, Section 5.2.2</a>.
*/

public Duration getMaxAge() {
return this.maxAge;
}
Expand Down Expand Up @@ -268,11 +274,15 @@ public interface ResponseCookieBuilder {

/**
* Set the cookie "Max-Age" attribute.
* <p>
* <ul>
* <li>Positive value: the cookie expires after the specified duration (persistent cookie).</li>
* <li>Zero: the cookie expires immediately (deleted).</li>
* <li>Negative value: no "Max-Age" attribute is sent, and the cookie becomes a <b>session cookie</b>
* (removed when the browser is closed).</li>
* </ul>
*
* <p>A positive value indicates when the cookie should expire relative
* to the current time. A value of 0 means the cookie should expire
* immediately. A negative value results in no "Max-Age" attribute in
* which case the cookie is removed when the browser is closed.
* <p>See <a href="https://datatracker.ietf.org/doc/html/rfc6265#section-5.2.2">RFC 6265, Section 5.2.2</a>.
*/
ResponseCookieBuilder maxAge(Duration maxAge);

Expand Down