Skip to content

Commit

Permalink
fix(cookies): remove session cookies when initializing the cookie man…
Browse files Browse the repository at this point in the history
…ager
  • Loading branch information
ItsChaceD authored Aug 18, 2023
1 parent a1ed6cc commit 037863b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ public CapacitorCookieManager(CookieStore store, CookiePolicy policy, Bridge bri
this.serverUrl = bridge.getServerUrl();
}

public void removeSessionCookies() {
this.webkitCookieManager.removeSessionCookies(null);
}

public String getSanitizedDomain(String url) throws URISyntaxException {
if (url == null || url.isEmpty()) {
url = this.serverUrl;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,17 @@ public class CapacitorCookies extends Plugin {
public void load() {
this.bridge.getWebView().addJavascriptInterface(this, "CapacitorCookiesAndroidInterface");
this.cookieManager = new CapacitorCookieManager(null, java.net.CookiePolicy.ACCEPT_ALL, this.bridge);
this.cookieManager.removeSessionCookies();
CookieHandler.setDefault(this.cookieManager);
super.load();
}

@Override
protected void handleOnDestroy() {
super.handleOnDestroy();
this.cookieManager.removeSessionCookies();
}

@JavascriptInterface
public boolean isEnabled() {
PluginConfig pluginConfig = getBridge().getConfig().getPluginConfiguration("CapacitorCookies");
Expand Down

0 comments on commit 037863b

Please # to comment.