Skip to main content

Cookies Management

General Info

If you are using any WebView for opening URLs for Activation and Login, you need to follow this recommendation for cookies management. The server each time opens a session when you open the URL in a WebView. During this session, WebView attaches data from cookies to request headers if they match the domain. For each session these data unique. So to avoid old data to be attached to a request please clean cookies before eqch flow.

When to clean Cookies

Before or after each session please remove cookies for a domain. If you do not do it, it can cause unexpected behavior.

iOS/Swift (Example)

Below you can find an example how you can remove cookies from WKWebView store.

Cookies Cache Clean (Swift)
class func cleanCookies() {
HTTPCookieStorage.shared.removeCookies(since: Date.distantPast)
print("All cookies deleted")

WKWebsiteDataStore.default().fetchDataRecords(ofTypes: WKWebsiteDataStore.allWebsiteDataTypes()) { records in
records.forEach { record in
WKWebsiteDataStore.default().removeData(ofTypes: record.dataTypes, for: [record], completionHandler: {})
print("Record \(record) deleted")
}
}
}

Android/Kotlin (Example)

Below you can find an example how you can remove cookies from WebView store.

Cookies Cache Clean (Swift)
fun cleanCookies(context: Context?) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) {
CookieManager.getInstance().removeAllCookies(null)
CookieManager.getInstance().flush()
} else if (context != null) {
val cookieSyncManager = CookieSyncManager.createInstance(context)
cookieSyncManager.startSync()
val cookieManager: CookieManager = CookieManager.getInstance()
cookieManager.removeAllCookie()
cookieManager.removeSessionCookie()
cookieSyncManager.stopSync()
cookieSyncManager.sync()
}
}

Cookies list

If you plan to manage your cookies manually you can take a look at this fields:

Cookie NameRequiredNeed to cleanPath
AUTH_SESSION_IDtruetrue/auth/realms/$tenantId/
AUTH_SESSION_ID_LEGACYtruetrue/auth/realms/$tenantId/
KC_RESTARTtruetrue/auth/realms/$tenantId/
IDPROUTINGtruetrue/auth/realms/$tenantId/protocol/openid-connect