Dart API Referencedart:ioCookie

Cookie abstract class

Representation of a cookie. For cookies received by the server as Cookie header values only name and value fields will be set. When building a cookie for the Set-Cookie header in the server and when receiving cookies in the client as Set-Cookie headers all fields can be used.

abstract class Cookie {
  /**
   * Creates a new cookie optionally setting the name and value.
   */
  factory Cookie([String name, String value]) => new _Cookie(name, value);

  /**
   * Creates a new cookie by parsing a header value from a Set-Cookie
   * header.
   */
  factory Cookie.fromSetCookieValue(String value) {
    return new _Cookie.fromSetCookieValue(value);
  }

  /**
   * Gets and sets the name.
   */
  String name;

  /**
   * Gets and sets the value.
   */
  String value;

  /**
   * Gets and sets the expiry date.
   */
  Date expires;

  /**
   * Gets and sets the max age. A value of [:0:] means delete cookie
   * now.
   */
  int maxAge;

  /**
   * Gets and sets the domain.
   */
  String domain;

  /**
   * Gets and sets the path.
   */
  String path;

  /**
   * Gets and sets whether this cookie is secure.
   */
  bool secure;

  /**
   * Gets and sets whether this cookie is HTTP only.
   */
  bool httpOnly;

  /**
   * Returns the formatted string representation of the cookie. The
   * string representation can be used for for setting the Cookie or
   * Set-Cookie headers
   */
  String toString();
}

Constructors

Creates a new cookie optionally setting the name and value.

factory Cookie([String name, String value]) => new _Cookie(name, value);

factory Cookie.fromSetCookieValue(String value) #

Creates a new cookie by parsing a header value from a Set-Cookie header.

factory Cookie.fromSetCookieValue(String value) {
  return new _Cookie.fromSetCookieValue(value);
}

Properties

String domain #

Gets and sets the domain.

String domain;

Date expires #

Gets and sets the expiry date.

Date expires;

bool httpOnly #

Gets and sets whether this cookie is HTTP only.

bool httpOnly;

int maxAge #

Gets and sets the max age. A value of 0 means delete cookie now.

int maxAge;

String name #

Gets and sets the name.

String name;

String path #

Gets and sets the path.

String path;

bool secure #

Gets and sets whether this cookie is secure.

bool secure;

String value #

Gets and sets the value.

String value;

Methods

String toString() #

Returns the formatted string representation of the cookie. The string representation can be used for for setting the Cookie or Set-Cookie headers

String toString();