All Products
Search
Document Center

SuperApp:Cross-domain

Last Updated:Jun 02, 2026

WVCookie provides cross-domain cookie JSAPIs for H5 applications and mini programs, letting you read and write cookies across domains that differ from the current page's domain.

Important

These API operations may fail. Handle both success and failure callbacks explicitly in your implementation.

WVCookie.read

Reads all cookies for a specified URL.

Use standard JavaScript (document.cookie) to read cookies from the same domain as the current page. To read cookies from a different domain, call WVCookie.read.

Input parameters

  • [string] url: The URL to read cookies from.

Callback parameters

Callback parameters are passed using the callback method. If cookies are retrieved from the specified URL, the success callback is invoked; otherwise, the failure callback is invoked.

  • [object] value: An object containing all cookies for the specified URL as key-value pairs.

var params = {
        // Replace with the URL whose cookies you want to read.
        url: 'http://xxx.com'
};
window.WindVane.call('WVCookie', 'read', params, function(e) {
        alert('success: ' + JSON.stringify(e));
}, function(e) {
        alert('failure: ' + JSON.stringify(e));
});

WVCookie.write

Writes a cookie to a specified domain.

Use standard JavaScript (document.cookie) to write a cookie to the same domain as the current page. To write a cookie to a different domain, call WVCookie.write.

Input parameters

  • [string] The cookie name and value as a key-value pair. Use any key name you choose — cookieKey in the example below is a placeholder, not a required field name.

  • [string] domain: The domain for which the cookie is valid.

  • [string] max-age (optional): The maximum age of the cookie, in seconds.

  • [string] path (optional): The path for which the cookie is valid. Defaults to '/'.

Note

You can include other cookie attributes such as max-age and path. Only one cookie can be set per call. To set multiple cookies, call this API once for each cookie.

Callback parameters

No values are returned by the callback. If the cookie is written successfully, the success callback is invoked; otherwise, the failure callback is invoked.

// The cookie to write. cookieKey and cookieValue in this example are
// placeholders — replace them with your actual cookie name and value.
var params = {
        cookieKey: 'cookieValue',
        domain: 'h5.m.taobao.com',
};
window.WindVane.call('WVCookie', 'write', params, function(e) {
        alert('success');
}, function(e) {
        alert('failure: ' + JSON.stringify(e));
});