DEV Community

Gowthaman Ravichandran
Gowthaman Ravichandran

Posted on

How to Manage Cookies?

I’m using the following code to launch a login page in my Flutter app via native Android code using CustomTabsIntent:

val customTabsIntent = CustomTabsIntent.Builder().build()
customTabsIntent.launchUrl(this, Uri.parse(loginUrl))

I want to manage cookies for the browser session opened using CustomTabsIntent. Specifically:

Add cookies (e.g., session tokens) before launching the URL.
Delete specific cookies or clear all cookies after the session.

I came across CookieManager in Android’s WebKit, but I’m unsure how to integrate it with CustomTabsIntent. Could someone guide me on how to:

Set cookies before launching the URL.
Delete existing cookies or clear cookies programmatically.

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay