org.apache.tapestry5

## Class CookieBuilder

- java.lang.Object
- - org.apache.tapestry5.CookieBuilder

-     public abstract class CookieBuilder
      extends Object

  A fluent API to create and write cookies. Used by the `Cookies` service.
  Since:
    5.4

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected String` | `domain`
    `protected Integer` | `maxAge`
    `protected String` | `name`
    `protected String` | `path`
    `protected Boolean` | `secure`
    `protected String` | `value`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `CookieBuilder(String name, String value)` Initialize a new CookieBuilder

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `abstract void` | `delete()` Deletes the cookie.
    `CookieBuilder` | `setDomain(String domain)` Set the domain for the cookie to be created.
    `CookieBuilder` | `setMaxAge(int maxAge)` Set how long the cookie should live.
    `CookieBuilder` | `setPath(String path)` Set the path for the cookie to be created.
    `CookieBuilder` | `setSecure(boolean secure)` Set the cookie's secure mode.
    `abstract void` | `write()` Sets defaults and writes the cookie to the client.

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

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

- - ### Field Detail

    - #### name

          protected final String name

    - #### value

          protected final String value

    - #### path

          protected String path

    - #### domain

          protected String domain

    - #### maxAge

          protected Integer maxAge

    - #### secure

          protected Boolean secure

  - ### Constructor Detail

    - #### CookieBuilder

          protected CookieBuilder(String name,
                                  String value)

      Initialize a new CookieBuilder
      Parameters:
        `name` - the name of the resulting cookie
        `value` - the value of the resulting cookie

  - ### Method Detail

    - #### setPath

          public CookieBuilder setPath(String path)

      Set the path for the cookie to be created. Defaults to `Request.getContextPath()`.
      Parameters:
        `path` - the path for the cookie
      Returns:
        the modified `CookieBuilder`

    - #### setDomain

          public CookieBuilder setDomain(String domain)

      Set the domain for the cookie to be created. Will not be set by default.
      Parameters:
        `domain` - the domain for the cookie
      Returns:
        the modified `CookieBuilder`

    - #### setMaxAge

          public CookieBuilder setMaxAge(int maxAge)

      Set how long the cookie should live. A value of `0` deletes a cookie, a value of `-1` deletes a cookie upon closing the browser. The default is defined by the symbol `org.apache.tapestry5.default-cookie-max-age`. The factory default for this value is the equivalent of one week.
      Parameters:
        `maxAge` - the cookie's maximum age in seconds
      Returns:
        the modified `CookieBuilder`

    - #### setSecure

          public CookieBuilder setSecure(boolean secure)

      Set the cookie's secure mode. Defaults to `Request.isSecure()`.
      Parameters:
        `secure` - whether to send the cookie over a secure channel only
      Returns:
        the modified `CookieBuilder`

    - #### write

          public abstract void write()

      Sets defaults and writes the cookie to the client.

    - #### delete

          public abstract void delete()

      Deletes the cookie.

${project.version} - Copyright © 2003-2015 The Apache Software Foundation.