Cookie

The Cookie class encapsulates the attributes of a single Cookie that is retrieved from the CookieDictionary collection of the Request and Response objects. Cookie implements all of the functionality of both the standard ASP IReadCookie and IWriteCookie interfaces.

public class Cookie
{
    public Boolean getHasKeys();
    public Enumerator getKeys();
    public String getItem(String itemName);
    public String getValue();
    public void setDomain(String domainName);
    public void setExpires(Date d);
    public void setItem(String name, String item);
    public void setValue(String value);
    public void setPath(String path);
    public void setSecure(Boolean secure);
}


Cookie Methods

public Boolean getHasKeys( )

Returns true if the cookie contains keys.

public Enumerator getKeys( )

Returns an Enumerator that can be used to access the keys for the cookie.

public String getItem(String itemName)

Returns the value for the key ItemName. When getItem is called, the cookie is assumed to be a dictionary cookie and item is treated as the key. In order to get the cookie string (non-parsed) or the value for a non-dictionary cookie, see getValue().

public String getValue( )

Returns the value of the cookie. If cookie is a dictionary key (i.e., getHasKeys( ) returns true), then the sequence of key/value pairs are URL-encoded and returned.

public void setDomain(String domainName)

Sets the Domain attribute of the cookie to the specified value.

public void setExpires(Date d)

Sets the Expires attribute of the cookie to the specified value. This date must be set in order for the cookie to be maintained after the session ends. If this attribute is not set to a date beyond the current date, the cookie will expire when the session ends.

public void setItem(String name, String item)

Treats the cookie as a dictionary cookie and item is the value for the cookie's name.

public void setValue(String value);

Treats the cookie as a simple cookie, and sets the cookie's value to value.

public void setPath(String path)

Sets the path attribute of the cookie to path. You can use this method to specify that the cookie should be sent only to requests on a particular path. If this attribute is not set, the application path is used.

public void setSecure(Boolean secure);

Sets the Secure attribute of the cookie to the specified value. You can use this method to specify that a cookie is secure. If you set this value to true, a Secure flag will be added to the Set-Cookie header sent to the client. The Secure flag instructs the client to use only secure means to access the server when sending back the cookie.