clearCookies method

Future<void> clearCookies()

Clears all cookies stored by Dio.

This method clears cookies from the current _cookieJar. On non-web platforms with PersistCookieJar, this clears both in-memory cookies and cookies persisted on disk.

Use this when you need to:

  • Log out a user
  • Reset authentication/session state
  • Ensure no stale cookies are reused

Implementation

Future<void> clearCookies() async {
  await _cookieJar?.deleteAll();
}