Class (WebCookie)

Manages behavior of cookies in Web components. All Web components in an application share a WebCookie. You can use the getCookieManager API in controller to obtain the WebCookie for subsequent cookie management.

NOTE

  • The initial APIs of this component are supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version.

  • The initial APIs of this class are supported since API version 8.

  • This API is supported since API version 8 and deprecated since API version 23. You are advised to use WebCookieManager instead.

  • The sample effect is subject to the actual device.

constructor(deprecated)

constructor()

Constructs a WebCookie object.

NOTE

This API is supported since API version 8 and deprecated since API version 23. No API is provided for substitute.

System capability: SystemCapability.Web.Webview.Core

setCookie(deprecated)

setCookie()

Sets the cookie. This API returns the result synchronously. true is returned if the operation is successful; otherwise, false is returned.

NOTE

This API is supported since API version 8 and deprecated since API version 9. You are advised to use setCookie9+ instead.

System capability: SystemCapability.Web.Webview.Core

saveCookie(deprecated)

saveCookie()

Saves the cookies in the memory to the drive. This API returns the result synchronously.

NOTE

This API is supported since API version 8 and deprecated since API version 9. You are advised to use saveCookieAsync9+ instead.

System capability: SystemCapability.Web.Webview.Core