1

I'm working on an application in which a user is automatically logged in to a website. However, on orientation changes the WebView will now save and restore its state in onSaveState() and onRestoreState. The only problem is that the cookies associated with the website are not stored and I cannot find a way to properly save the cookies now.

The target version of Android is 2.1. Any help or advice is welcome.

SegF4ult
  • 522
  • 4
  • 16

1 Answers1

2
CookieManager cookieManager = CookieManager.getInstance();
cookieManager.removeSessionCookie();
cookieManager.setCookie("www.example.com", name + "=" + value + ";");
CookieSyncManager.getInstance().sync();

NB! Give the Android enough time to proccess cookies. Source.

EDIT

Broken link: source

MilapTank
  • 9,988
  • 7
  • 38
  • 53
Indrek Kõue
  • 6,449
  • 8
  • 37
  • 69