Skip to content

httpClient.ClearCookies

Overview

Used when deleting the cookies held by "httpClient" in a "Server Script". Use it when logging in to the same external service again with another account.

For the scope in which httpClient holds cookies, refer to "httpClient".

Limitations

  1. When a URL is specified, the cookies deleted are those sent to the host of that URL. They are deleted regardless of the path of the cookie. Cookies of other hosts are not deleted.
  2. Cookies issued by a parent domain without the Domain attribute are not deleted even if a URL of a subdomain is specified. Cookies whose Domain attribute specifies the parent domain (Domain=example.com) are deleted when a URL of a subdomain is specified.
  3. Cookies issued by a subdomain without the Domain attribute are not deleted even if a URL of the parent domain is specified.
  4. Cookies whose path contains "?" or "#" are not deleted even if a URL is specified. Omit the argument to delete all cookies.

Syntax

httpClient.ClearCookies();
httpClient.ClearCookies(url);

Parameters

Parameter Type Required Overview
url string - The URL whose cookies are deleted (e.g. 'https://servername/'). If omitted, all cookies held are deleted. If an empty string, an invalid URL, or a URL other than http/https is specified, no error occurs and nothing is deleted.

Return Value

There is no return value.

Usage Examples

Sample That Logs In Again with Another Account

The following example logs in to an external service with account A and processes data, deletes the cookies of that service, and then logs in again with account B.

const SERVICE_URL = 'https://servername';

// Log in with account A and get data (the cookies received at login are sent)
httpClient.RequestUri = SERVICE_URL + '/api/login';
httpClient.Content = JSON.stringify({ user: 'accountA', password: '.....' });
httpClient.Post();
httpClient.RequestUri = SERVICE_URL + '/api/data';
let dataA = httpClient.Get();

// Delete the cookies of this service
httpClient.ClearCookies(SERVICE_URL);

// Log in again with account B
httpClient.RequestUri = SERVICE_URL + '/api/login';
httpClient.Content = JSON.stringify({ user: 'accountB', password: '.....' });
httpClient.Post();
httpClient.RequestUri = SERVICE_URL + '/api/data';
let dataB = httpClient.Get();

Supported Versions

Supported versions Body
1.5.10.0 and later Added function