Package org.springframework.web.util

# Class CookieGenerator

java.lang.Object
org.springframework.web.util.CookieGenerator

@Deprecated public class CookieGenerator extends Object
Deprecated.
as of 6.0 in favor of `ResponseCookie`
Helper class for cookie generation, carrying cookie descriptor settings as bean properties and being able to add and remove cookie to/from a given response.

Can serve as base class for components that generate specific cookies.

Since:
  1.1.4
Author:
  Juergen Hoeller
See Also:
  - `addCookie(jakarta.servlet.http.HttpServletResponse, java.lang.String)`
  - `removeCookie(jakarta.servlet.http.HttpServletResponse)`

## Field Summary

Fields
Modifier and Type
Field
Description
`static final String`
`DEFAULT_COOKIE_PATH`
Deprecated.
Default path that cookies will be visible to: "/", i.e.
`protected final org.apache.commons.logging.Log`
`logger`
Deprecated.

## Constructor Summary

Constructors
Constructor
Description
`CookieGenerator()`
Deprecated.

## Method Summary

Modifier and Type
Method
Description
`void`
`addCookie(HttpServletResponse response, String cookieValue)`
Deprecated.
Add a cookie with the given value to the response, using the cookie descriptor settings of this generator.
`protected Cookie`
`createCookie(String cookieValue)`
Deprecated.
Create a cookie with the given value, using the cookie descriptor settings of this generator (except for "cookieMaxAge").
`String`
`getCookieDomain()`
Deprecated.
Return the domain for cookies created by this generator, if any.
`Integer`
`getCookieMaxAge()`
Deprecated.
Return the maximum age for cookies created by this generator.
`String`
`getCookieName()`
Deprecated.
Return the given name for cookies created by this generator.
`String`
`getCookiePath()`
Deprecated.
Return the path for cookies created by this generator.
`boolean`
`isCookieHttpOnly()`
Deprecated.
Return whether the cookie is supposed to be marked with the "HttpOnly" attribute.
`boolean`
`isCookieSecure()`
Deprecated.
Return whether the cookie should only be sent using a secure protocol, such as HTTPS (SSL).
`void`
`removeCookie(HttpServletResponse response)`
Deprecated.
Remove the cookie that this generator describes from the response.
`void`
`setCookieDomain(String cookieDomain)`
Deprecated.
Use the given domain for cookies created by this generator.
`void`
`setCookieHttpOnly(boolean cookieHttpOnly)`
Deprecated.
Set whether the cookie is supposed to be marked with the "HttpOnly" attribute.
`void`
`setCookieMaxAge(Integer cookieMaxAge)`
Deprecated.
Use the given maximum age (in seconds) for cookies created by this generator.
`void`
`setCookieName(String cookieName)`
Deprecated.
Use the given name for cookies created by this generator.
`void`
`setCookiePath(String cookiePath)`
Deprecated.
Use the given path for cookies created by this generator.
`void`
`setCookieSecure(boolean cookieSecure)`
Deprecated.
Set whether the cookie should only be sent using a secure protocol, such as HTTPS (SSL).

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### DEFAULT_COOKIE_PATH

public static final String DEFAULT_COOKIE_PATH
Deprecated.
Default path that cookies will be visible to: "/", i.e. the entire server.

See Also:
  - Constant Field Values

### logger

protected final org.apache.commons.logging.Log logger
Deprecated.

## Constructor Details

### CookieGenerator

public CookieGenerator()
Deprecated.

## Method Details

### setCookieName

public void setCookieName(@Nullable String cookieName)
Deprecated.
Use the given name for cookies created by this generator.

See Also:
  - `Cookie.getName()`

### getCookieName

@Nullable public String getCookieName()
Deprecated.
Return the given name for cookies created by this generator.

### setCookieDomain

public void setCookieDomain(@Nullable String cookieDomain)
Deprecated.
Use the given domain for cookies created by this generator. The cookie is only visible to servers in this domain.

See Also:
  - `Cookie.setDomain(java.lang.String)`

### getCookieDomain

@Nullable public String getCookieDomain()
Deprecated.
Return the domain for cookies created by this generator, if any.

### setCookiePath

public void setCookiePath(String cookiePath)
Deprecated.
Use the given path for cookies created by this generator. The cookie is only visible to URLs in this path and below.

See Also:
  - `Cookie.setPath(java.lang.String)`

### getCookiePath

public String getCookiePath()
Deprecated.
Return the path for cookies created by this generator.

### setCookieMaxAge

public void setCookieMaxAge(@Nullable Integer cookieMaxAge)
Deprecated.
Use the given maximum age (in seconds) for cookies created by this generator. Useful special value: -1 ... not persistent, deleted when client shuts down.

Default is no specific maximum age at all, using the Servlet container's default.

See Also:
  - `Cookie.setMaxAge(int)`

### getCookieMaxAge

@Nullable public Integer getCookieMaxAge()
Deprecated.
Return the maximum age for cookies created by this generator.

### setCookieSecure

public void setCookieSecure(boolean cookieSecure)
Deprecated.
Set whether the cookie should only be sent using a secure protocol, such as HTTPS (SSL). This is an indication to the receiving browser, not processed by the HTTP server itself.

Default is "false".

See Also:
  - `Cookie.setSecure(boolean)`

### isCookieSecure

public boolean isCookieSecure()
Deprecated.
Return whether the cookie should only be sent using a secure protocol, such as HTTPS (SSL).

### setCookieHttpOnly

public void setCookieHttpOnly(boolean cookieHttpOnly)
Deprecated.
Set whether the cookie is supposed to be marked with the "HttpOnly" attribute.

Default is "false".

See Also:
  - `Cookie.setHttpOnly(boolean)`

### isCookieHttpOnly

public boolean isCookieHttpOnly()
Deprecated.
Return whether the cookie is supposed to be marked with the "HttpOnly" attribute.

### addCookie

public void addCookie(HttpServletResponse response, String cookieValue)
Deprecated.
Add a cookie with the given value to the response, using the cookie descriptor settings of this generator.

Delegates to `createCookie(java.lang.String)` for cookie creation.

Parameters:
  `response` - the HTTP response to add the cookie to
  `cookieValue` - the value of the cookie to add
See Also:
  - `setCookieName(java.lang.String)`
  - `setCookieDomain(java.lang.String)`
  - `setCookiePath(java.lang.String)`
  - `setCookieMaxAge(java.lang.Integer)`

### removeCookie

public void removeCookie(HttpServletResponse response)
Deprecated.
Remove the cookie that this generator describes from the response. Will generate a cookie with empty value and max age 0.

Delegates to `createCookie(java.lang.String)` for cookie creation.

Parameters:
  `response` - the HTTP response to remove the cookie from
See Also:
  - `setCookieName(java.lang.String)`
  - `setCookieDomain(java.lang.String)`
  - `setCookiePath(java.lang.String)`

### createCookie

protected Cookie createCookie(String cookieValue)
Deprecated.
Create a cookie with the given value, using the cookie descriptor settings of this generator (except for "cookieMaxAge").

Parameters:
  `cookieValue` - the value of the cookie to crate
Returns:
  the cookie
See Also:
  - `setCookieName(java.lang.String)`
  - `setCookieDomain(java.lang.String)`
  - `setCookiePath(java.lang.String)`