openharmony 鸿蒙 capi-web-arkweb-cookiemanagerapi

2026-08-25 浏览 (1)

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

NameDescription
size_t sizeSize of the struct.

Member Functions

NameDescription
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

NameDescription
const char* urlURL of the cookie to obtain. A complete URL is recommended.
bool incognitoWhether 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 includeHttpOnlyWhether to include the cookie marked as HttpOnly in cookieValue.
char** cookieValueCookie value of the URL.

Returns

TypeDescription
ArkWeb_ErrorCodeError 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

NameDescription
const char* urlURL of the specified cookie. It must be a complete URL.
const char* cookieValueCookie value to be set.
bool incognitoWhether 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 includeHttpOnlyWhether to overwrite the cookie marked as HTTPOnly. The value true means to overwrite the cookie marked as HTTPOnly, and false means the opposite.

Returns

TypeDescription
ArkWeb_ErrorCodeError 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

NameDescription
bool incognitoWhether 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

TypeDescription
booltrue is returned if the cookie exists; otherwise, false is returned.

clearAllCookiesSync()

void (*clearAllCookiesSync)(bool incognito)

Description

Clears all cookies.

Parameters

NameDescription
bool incognitoWhether 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

openharmony 鸿蒙 arkts-apis-webview-NativeMediaPlayerHandler

openharmony 鸿蒙 capi-web-arkweb-proxymethodwithresult

  • 所属分类: 后端技术
  • 本文标签: 鸿蒙 软件
  • 版权声明: 本文链接 https://seaxiang.com/blog/3oAsn0D7