Android
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
          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
          void  setCookie(String url, String value)
Set cookie for a given url.

Protected Methods

          Object  clone()
Returns 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 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. If this is called before any WebView is created or outside of WebView context, the caller needs to call createInstance(Context) first.

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 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()

Returns 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.

Returns

  • Object a shallow copy of this object.
Copyright 2007 Google Inc. Build 0.9_r1-98467 - 14 Aug 2008 18:48