# Class Cookie

java.lang.Object
com.codename1.io.Cookie

All Implemented Interfaces:
  `Externalizable`

public class Cookie extends Object implements Externalizable
A cookie for an HTTP request

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final String`
  `STORAGE_NAME`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `Cookie()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static void`
  `clearCookiesFromStorage()`
  Clears all cookies history from storage
  `void`
  `externalize(DataOutputStream out)`
  Allows us to store an object state, this method must be implemented in order to save the state of an object
  `String`
  `getDomain()`

  ###### Returns

  `long`
  `getExpires()`

  ###### Returns

  `String`
  `getName()`

  ###### Returns

  `String`
  `getObjectId()`
  The object id must be unique, it is used to identify the object when loaded even when it is obfuscated.
  `String`
  `getPath()`
  `String`
  `getValue()`

  ###### Returns

  `int`
  `getVersion()`
  Returns the version for the current persistance code, the version will be pased to internalized thus allowing the internalize method to recognize classes persisted in older revisions
  `void`
  `internalize(int version, DataInputStream in)`
  Loads the object from the input stream and allows deserialization
  `static boolean`
  `isAutoStored()`
  Returns true if the Cookies are auto stored to storage
  `boolean`
  `isHttpOnly()`
  `boolean`
  `isSecure()`
  `static void`
  `setAutoStored(boolean autoStored)`
  This method configures the auto storage of cookies
  `void`
  `setDomain(String domain)`

  ###### Parameters

  `void`
  `setExpires(long expires)`

  ###### Parameters

  `void`
  `setHttpOnly(boolean httpOnly)`
  `void`
  `setName(String name)`

  ###### Parameters

  `void`
  `setPath(String path)`
  `void`
  `setSecure(boolean secure)`
  `void`
  `setValue(String value)`

  ###### Parameters

  `String`
  `toString()`

  ### Methods inherited from class Object

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

- ## Field Details

  - ### STORAGE_NAME

    public static final String STORAGE_NAME
    See Also:
      - Constant Field Values

- ## Constructor Details

  - ### Cookie

    public Cookie()

- ## Method Details

  - ### isAutoStored

    public static boolean isAutoStored()

    Returns true if the Cookies are auto stored to storage

    ###### Returns

    autoStored

  - ### setAutoStored

    public static void setAutoStored(boolean autoStored)

    This method configures the auto storage of cookies

    ###### Parameters

    - `autoStored`

  - ### clearCookiesFromStorage

    public static void clearCookiesFromStorage()
    Clears all cookies history from storage

  - ### getName

    public String getName()

    ###### Returns

    the name

  - ### setName

    public void setName(String name)

    ###### Parameters

    - `name`: the name to set

  - ### isSecure

    public boolean isSecure()

  - ### setSecure

    public void setSecure(boolean secure)

  - ### isHttpOnly

    public boolean isHttpOnly()

  - ### setHttpOnly

    public void setHttpOnly(boolean httpOnly)

  - ### getPath

    public String getPath()

  - ### setPath

    public void setPath(String path)

  - ### getValue

    public String getValue()

    ###### Returns

    the value

  - ### setValue

    public void setValue(String value)

    ###### Parameters

    - `value`: the value to set

  - ### getDomain

    public String getDomain()

    ###### Returns

    the domain

  - ### setDomain

    public void setDomain(String domain)

    ###### Parameters

    - `domain`: the domain to set

  - ### getExpires

    public long getExpires()

    ###### Returns

    the expires

  - ### setExpires

    public void setExpires(long expires)

    ###### Parameters

    - `expires`: the expires to set

  - ### getVersion

    public int getVersion()

    Returns the version for the current persistance code, the version will be pased to internalized thus allowing the internalize method to recognize classes persisted in older revisions

    ###### Returns

    version number for the persistant code

    Specified by:
      `getVersion` in interface `Externalizable`

  - ### externalize

    public void externalize(DataOutputStream out) throws IOException

    Allows us to store an object state, this method must be implemented in order to save the state of an object

    ###### Parameters

    - `out`: the stream into which the object must be serialized

    ###### Throws

    - `java.io.IOException`: the method may throw an exception
    Specified by:
      `externalize` in interface `Externalizable`
    Throws:
      `IOException`

  - ### internalize

    public void internalize(int version, DataInputStream in) throws IOException

    Loads the object from the input stream and allows deserialization

    ###### Parameters

    - `version`: the version the class returned during the externalization processs

    - `in`: the input stream used to load the class

    ###### Throws

    - `java.io.IOException`: the method may throw an exception
    Specified by:
      `internalize` in interface `Externalizable`
    Throws:
      `IOException`

  - ### getObjectId

    public String getObjectId()

    The object id must be unique, it is used to identify the object when loaded even when it is obfuscated.

    ###### Returns

    a unique id

    Specified by:
      `getObjectId` in interface `Externalizable`

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `Object`