Skip to content

Commit 315698b

Browse files
committed
Clarified cookieMaxAge default
Issue: SPR-15155 (cherry picked from commit 874b653)
1 parent 6deccf1 commit 315698b

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

spring-web/src/main/java/org/springframework/web/util/CookieGenerator.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2015 the original author or authors.
2+
* Copyright 2002-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -55,7 +55,7 @@ public class CookieGenerator {
5555

5656
private String cookiePath = DEFAULT_COOKIE_PATH;
5757

58-
private Integer cookieMaxAge = null;
58+
private Integer cookieMaxAge;
5959

6060
private boolean cookieSecure = false;
6161

@@ -111,7 +111,9 @@ public String getCookiePath() {
111111

112112
/**
113113
* Use the given maximum age (in seconds) for cookies created by this generator.
114-
* Useful special value: -1 ... not persistent, deleted when client shuts down
114+
* Useful special value: -1 ... not persistent, deleted when client shuts down.
115+
* <p>Default is no specific maximum age at all, using the Servlet container's
116+
* default.
115117
* @see javax.servlet.http.Cookie#setMaxAge
116118
*/
117119
public void setCookieMaxAge(Integer cookieMaxAge) {
@@ -128,7 +130,8 @@ public Integer getCookieMaxAge() {
128130
/**
129131
* Set whether the cookie should only be sent using a secure protocol,
130132
* such as HTTPS (SSL). This is an indication to the receiving browser,
131-
* not processed by the HTTP server itself. Default is "false".
133+
* not processed by the HTTP server itself.
134+
* <p>Default is "false".
132135
* @see javax.servlet.http.Cookie#setSecure
133136
*/
134137
public void setCookieSecure(boolean cookieSecure) {
@@ -145,7 +148,7 @@ public boolean isCookieSecure() {
145148

146149
/**
147150
* Set whether the cookie is supposed to be marked with the "HttpOnly" attribute.
148-
* <p>Note that this feature is only available on Servlet 3.0 and higher.
151+
* <p>Default is "false".
149152
* @see javax.servlet.http.Cookie#setHttpOnly
150153
*/
151154
public void setCookieHttpOnly(boolean cookieHttpOnly) {

src/asciidoc/web-mvc.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3518,7 +3518,7 @@ maximum age. Find below an example of defining a `CookieLocaleResolver`.
35183518
| The name of the cookie
35193519

35203520
| cookieMaxAge
3521-
| Integer.MAX_INT
3521+
| Servlet container default
35223522
| The maximum time a cookie will stay persistent on the client. If -1 is specified, the
35233523
cookie will not be persisted; it will only be available until the client shuts down
35243524
their browser.

0 commit comments

Comments
 (0)