English | Site Directory

Android - An Open Handset Alliance Project

android.webkit
public final class

android.webkit.CookieManager

java.lang.Object
android.webkit.CookieManager

CookieManager manages cookies according to RFC2109 spec.

Summary

Public Methods

  synchronized      boolean  acceptCookie()
Return whether cookie is enabled
  synchronized      String  getCookie(String url)
Get cookie(s) for a given url so that it can be set to "cookie:" in http request header.
  synchronized    static  CookieManager  getInstance()
Get a singleton CookieManager
  synchronized      boolean  hasCookies()
Return true if there are stored cookies.
  synchronized      void  removeAllCookie()
Remove all cookies
  synchronized      void  removeExpiredCookie()
Remove all expired cookies
  synchronized      void  removeSessionCookie()
Remove all session cookies, which are cookies without expiration date
  synchronized      void  setAcceptCookie(boolean accept)
Control whether cookie is enabled or disabled
  synchronized      void  setCookie(String url, String value)
Set cookie for a given url.

Protected Methods

        Object  clone()
Answers a new instance of the same class as the receiver, whose slots have been filled in with the values in the slots of the receiver.
Methods inherited from class java.lang.Object

Details

Public Methods

public synchronized boolean acceptCookie()

Return whether cookie is enabled

Returns

  • TRUE if accept cookie

public synchronized String getCookie(String url)

Get cookie(s) for a given url so that it can be set to "cookie:" in http request header.

Parameters

url The url needs cookie

Returns

  • The cookies in the format of NAME=VALUE [; NAME=VALUE]

public static synchronized CookieManager getInstance()

Get a singleton CookieManager

Returns

  • CookieManager

public synchronized boolean hasCookies()

Return true if there are stored cookies.

public synchronized void removeAllCookie()

Remove all cookies

public synchronized void removeExpiredCookie()

Remove all expired cookies

public synchronized void removeSessionCookie()

Remove all session cookies, which are cookies without expiration date

public synchronized void setAcceptCookie(boolean accept)

Control whether cookie is enabled or disabled

Parameters

accept TRUE if accept cookie

public synchronized void setCookie(String url, String value)

Set cookie for a given url. The old cookie with same host/path/name will be removed. The new cookie will be added if it is not expired or it does not have expiration which implies it is session cookie.

Parameters

url The url which cookie is set for
value The value for set-cookie: in http response header

Protected Methods

protected Object clone()

Answers a new instance of the same class as the receiver, whose slots have been filled in with the values in the slots of the receiver.

Classes which wish to support cloning must specify that they implement the Cloneable interface, since the implementation checks for this.

Build m5-rc15i - 10 Jun 2008 13:54