Class Cookies

public class Cookies
extends Object
Provides access to browser cookies stored on the client. Because of browser restrictions, you will only be able to access cookies associated with the current page's domain.

Methods

getCookie(String)Gets the cookie associated with the given key.
setCookie(String, String, Date)Sets a cookie.
setCookie(String, String, Date, String, String, boolean)Sets a cookie.

Method Detail

getCookie

public static String getCookie(String key)
Gets the cookie associated with the given key.

Parameters

key
the key of the cookie to be retrieved

Return Value

the cookie's value.

setCookie

public static void setCookie(String name, String value, Date expires)
Sets a cookie.

Parameters

name
the cookie's name
value
the cookie's value
expires
when the cookie expires

setCookie

public static void setCookie(String name, String value, Date expires, String domain, String path, boolean secure)
Sets a cookie.

Parameters

name
the cookie's name
value
the cookie's value
expires
when the cookie expires
domain
the domain to be associated with this cookie
path
the path to be associated with this cookie
secure
true to make this a secure cookie