ArkWeb_CookieManagerAPI
typedef struct {...} ArkWeb_CookieManagerAPI
Overview
Defines the CookieManager API of ArkWeb. Before calling this API, you are advised to use ARKWEB_MEMBER_MISSING to check whether the function struct has the corresponding pointer to avoid crash caused by mismatch between the SDK and the device ROM. The CookieManager APIs must be called on the UI thread through OH_ArkWeb_GetNativeAPI.
Since: 12
Related module: Web
Header file: arkweb_type.h
Summary
Member Variables
| Name | Description |
|---|---|
| size_t size | Size of the struct. |
Member Functions
| Name | Description |
|---|---|
| ArkWeb_ErrorCode (*fetchCookieSync)(const char* url, bool incognito, bool includeHttpOnly, char** cookieValue) | Obtains the cookie value of a specified URL. |
| ArkWeb_ErrorCode (*configCookieSync)(const char* url,const char* cookieValue, bool incognito, bool includeHttpOnly) | Sets the cookie value of a specified URL. |
| bool (*existCookies)(bool incognito) | Checks whether cookies exist. |
| void (*clearAllCookiesSync)(bool incognito) | Clears all cookies. |
| void (*clearSessionCookiesSync)() | Clears all session cookies. |
Member Function Description
fetchCookieSync()
ArkWeb_ErrorCode (*fetchCookieSync)(const char* url, bool incognito, bool includeHttpOnly, char** cookieValue)
Description
Obtains the cookie value of a specified URL.
Parameters
| Name | Description |
|---|---|
| const char* url | URL of the cookie to obtain. A complete URL is recommended. |
| bool incognito | Whether to obtain the webview memory cookie in incognito mode or in non-incognito mode. The value true means to obtain the webview memory cookie in incognito mode, and the value false means the opposite. |
| bool includeHttpOnly | Whether to include the cookie marked as HttpOnly in cookieValue. |
| char** cookieValue | Cookie value of the URL. |
Returns
| Type | Description |
|---|---|
| ArkWeb_ErrorCode | Error code. ARKWEB_SUCCESS: The cookie is successfully obtained. ARKWEB_INVALID_URL: The URL is invalid. ARKWEB_INVALID_PARAM: The parameter is invalid. |
configCookieSync()
ArkWeb_ErrorCode (*configCookieSync)(const char* url,const char* cookieValue, bool incognito, bool includeHttpOnly)
Description
Sets the cookie value of a specified URL.
Parameters
| Name | Description |
|---|---|
| const char* url | URL of the specified cookie. It must be a complete URL. |
| const char* cookieValue | Cookie value to be set. |
| bool incognito | Whether to set the cookie of corresponding URL in incognito mode. The value true means to set the cookie of corresponding URL in incognito mode, and false means the opposite. |
| bool includeHttpOnly | Whether to overwrite the cookie marked as HTTPOnly. The value true means to overwrite the cookie marked as HTTPOnly, and false means the opposite. |
Returns
| Type | Description |
|---|---|
| ArkWeb_ErrorCode | Error code. ARKWEB_SUCCESS: The cookie is successfully obtained. ARKWEB_INVALID_URL: The URL is invalid. ARKWEB_INVALID_COOKIE_VALUE: The cookie value is invalid. |
existCookies()
bool (*existCookies)(bool incognito)
Description
Checks whether cookies exist.
Parameters
| Name | Description |
|---|---|
| bool incognito | Whether the cookie exists in incognito mode or in non-incognito mode. The value true indicates that the cookie exists in incognito mode, and false indicates the opposite. |
Returns
| Type | Description |
|---|---|
| bool | true is returned if the cookie exists; otherwise, false is returned. |
clearAllCookiesSync()
void (*clearAllCookiesSync)(bool incognito)
Description
Clears all cookies.
Parameters
| Name | Description |
|---|---|
| bool incognito | Whether to clear all cookies in incognito mode. The value true means to clear all cookies in incognito mode, and false means the opposite. |
clearSessionCookiesSync()
void (*clearSessionCookiesSync)()
Description
Clears all session cookies.
你可能感兴趣的鸿蒙文章
openharmony 鸿蒙 arkts-apis-webview-WebviewController
openharmony 鸿蒙 arkts-apis-webview-t
openharmony 鸿蒙 arkts-apis-webview
openharmony 鸿蒙 capi-arkweb-type-h
openharmony 鸿蒙 arkts-basic-components-web-FullScreenExitHandler
openharmony 鸿蒙 arkts-apis-webview-WebDownloadManager
openharmony 鸿蒙 arkts-basic-components-web-VerifyPinHandler
openharmony 鸿蒙 capi-web-arkweb-webmessage8h