CookieManager.SetCookie Method

Definition

Overloads

SetCookie(String, String)

Sets a single cookie (key-value pair) for the given URL.

SetCookie(String, String, IValueCallback)

Sets a single cookie (key-value pair) for the given URL.

SetCookie(String, String)

Sets a single cookie (key-value pair) for the given URL.

[Android.Runtime.Register("setCookie", "(Ljava/lang/String;Ljava/lang/String;)V", "GetSetCookie_Ljava_lang_String_Ljava_lang_String_Handler")]
public abstract void SetCookie (string? url, string? value);
[<Android.Runtime.Register("setCookie", "(Ljava/lang/String;Ljava/lang/String;)V", "GetSetCookie_Ljava_lang_String_Ljava_lang_String_Handler")>]
abstract member SetCookie : string * string -> unit

Parameters

url
String

the URL for which the cookie is to be set

value
String

the cookie as a string, using the format of the 'Set-Cookie' HTTP response header

Attributes

Remarks

Sets a single cookie (key-value pair) for the given URL. Any existing cookie with the same host, path and name will be replaced with the new cookie. The cookie being set will be ignored if it is expired. To set multiple cookies, your application should invoke this method multiple times.

The value parameter must follow the format of the Set-Cookie HTTP response header defined by RFC6265bis. This is a key-value pair of the form "key=value", optionally followed by a list of cookie attributes delimited with semicolons (ex. "key=value; Max-Age=123"). Please consult the RFC specification for a list of valid attributes.

<p class="note"><b>Note:</b> if specifying a value containing the "Secure" attribute, url must use the "https://" scheme.

Java documentation for android.webkit.CookieManager.setCookie(java.lang.String, java.lang.String).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

SetCookie(String, String, IValueCallback)

Sets a single cookie (key-value pair) for the given URL.

[Android.Runtime.Register("setCookie", "(Ljava/lang/String;Ljava/lang/String;Landroid/webkit/ValueCallback;)V", "GetSetCookie_Ljava_lang_String_Ljava_lang_String_Landroid_webkit_ValueCallback_Handler")]
public abstract void SetCookie (string? url, string? value, Android.Webkit.IValueCallback? callback);
[<Android.Runtime.Register("setCookie", "(Ljava/lang/String;Ljava/lang/String;Landroid/webkit/ValueCallback;)V", "GetSetCookie_Ljava_lang_String_Ljava_lang_String_Landroid_webkit_ValueCallback_Handler")>]
abstract member SetCookie : string * string * Android.Webkit.IValueCallback -> unit

Parameters

url
String

the URL for which the cookie is to be set

value
String

the cookie as a string, using the format of the 'Set-Cookie' HTTP response header

callback
IValueCallback

a callback to be executed when the cookie has been set

Attributes

Remarks

Sets a single cookie (key-value pair) for the given URL. Any existing cookie with the same host, path and name will be replaced with the new cookie. The cookie being set will be ignored if it is expired. To set multiple cookies, your application should invoke this method multiple times.

The value parameter must follow the format of the Set-Cookie HTTP response header defined by RFC6265bis. This is a key-value pair of the form "key=value", optionally followed by a list of cookie attributes delimited with semicolons (ex. "key=value; Max-Age=123"). Please consult the RFC specification for a list of valid attributes.

This method is asynchronous. If a ValueCallback is provided, ValueCallback#onReceiveValue will be called on the current thread's android.os.Looper once the operation is complete. The value provided to the callback indicates whether the cookie was set successfully. You can pass null as the callback if you don't need to know when the operation completes or whether it succeeded, and in this case it is safe to call the method from a thread without a Looper.

<p class="note"><b>Note:</b> if specifying a value containing the "Secure" attribute, url must use the "https://" scheme.

Java documentation for android.webkit.CookieManager.setCookie(java.lang.String, java.lang.String, android.webkit.ValueCallback<java.lang.Boolean>).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to