Skip to content

Guides

WebView App Keeps Logging Out? How to Check Your Login Cookie

Users sign in, close the app and are signed out again. Here is how to read your login cookie, which side has to change and how to retest, checked December 2026.

10 min read

When a WebView app keeps logging out, start with the cookie your site sets at sign-in. If it has no Expires or Max-Age, it is a session cookie, which is not meant to last. If it comes from a different site than the page, Android WebView may be refusing it as a third-party cookie. If neither applies, check the expiry time, your server's own session timeout and how your app stores cookies. This guide was checked against Android and MDN documentation in December 2026.

Why does my WebView app keep logging me out?

"Logged out" can come from several places that look the same on screen. The timing of the logout is a useful first clue. Treat this table as a way to narrow things down, not as proof.

A starting point for diagnosis, based on documented cookie behavior (December 2026)
When users get signed outCheck firstWho can change it
After closing and reopening the appWhether the login cookie has Expires or Max-AgeWebsite
Right after signing in, or on the next pageWhether the cookie is third-party, or marked SameSite=None without SecureWebsite, sometimes the app
After a fixed period, such as a day or two weeksThe cookie's expiry and the server's session timeoutWebsite
Only in the app, while the phone browser stays signed inHow the app handles cookies, and which sign-in method you useApp builder, then website
On a new phoneCredential restore, which is a separate topicBoth

The last row is covered in our guide to the zero-tap sign-in requirement. It is about moving to a new device, not about staying signed in on the same one.

This is the first thing to rule out. MDN's Set-Cookie reference says a cookie with neither Expires nor Max-Age is a session cookie, removed when the client shuts down. It also warns that many browsers restore sessions, which brings session cookies back. So your site can seem to remember people in a desktop or phone browser while the cookie was never set to last. Do not expect an app to behave the same way.

Ask your developer to look at the Set-Cookie header on the response that signs a user in. These two examples show the difference:

Illustrative headers; your cookie name and value will differ
Header sent at sign-inWhat it means
Set-Cookie: sessionid=abc123; Secure; HttpOnlySession cookie. No lifetime is set.
Set-Cookie: sessionid=abc123; Max-Age=2592000; Secure; HttpOnlyPersistent cookie. 2,592,000 seconds is 30 days.

If both Expires and Max-Age are present, Max-Age wins. A "Remember me" box often controls which kind of cookie you get. In one WordPress.org support thread about users being signed out when an app closed, the person who asked reported that having users tick "Remember me" solved it. That is one report, not a rule, but it is a quick thing to try.

By default, yes for modern apps. Android's CookieManager reference says WebView accepts cookies by default, but apps targeting Android 5.0 (Lollipop) or later disallow third-party cookies unless the app turns them on for that WebView.

This can matter if sign-in runs on a different site from the pages your app shows, for example a hosted login service or a member area loaded in a frame. Subdomains and redirects can behave differently, so have your developer confirm which domain sets the cookie and which page needs it. Also check the attributes: MDN says a cookie with SameSite=None must also be Secure.

If the cookie really is third-party, there are two routes. The website can move sign-in so the cookie is first-party, or the app can call setAcceptThirdPartyCookies for its WebView. The second is an app change, so ask your builder whether it is possible. A sign-in with Google that fails with an error screen is a different problem, explained in our disallowed_useragent guide.

What can the app do to keep cookies?

If your cookie is persistent and first-party and users still lose it, give your app developer these specific questions. Each refers to a method in Android's CookieManager reference.

  • Does the app call setAcceptCookie(false) anywhere? The default is true.
  • Does it call removeAllCookies or removeSessionCookies at launch or exit? The first removes every cookie, the second every cookie without an expiry date.
  • Does it call flush after sign-in? Android describes flush as making sure cookies are written to persistent storage. The call blocks until it finishes.
  • Does the app need third-party cookies, and if so, is setAcceptThirdPartyCookies enabled on the right WebView?

Be careful with advice to force every cookie to stay forever. Banking, health and admin areas often expire sessions on purpose. The goal is for the app to keep what your site intends to keep.

Some sites keep the login token in browser storage instead of a cookie. That depends on WebView settings and on your own code, so tell your developer where the token lives. If pages come up blank rather than signed out, use the white screen checklist.

How do I test whether users stay signed in?

Run this on a real phone with a test account, before and after any change. Change one thing at a time so you know what made the difference.

  1. 1

    Install and sign in

    Use a fresh install. Tick "Remember me" if your site has it, and note the time.

  2. 2

    Switch away and back

    Open another app for a minute, then return. Note whether you are still signed in.

  3. 3

    Close from recent apps

    Swipe the app away, reopen it and check again.

  4. 4

    Restart the phone

    Reboot, open the app and check again.

  5. 5

    Wait overnight

    Check the next day, then again after the lifetime your cookie is meant to have.

  6. 6

    Compare with the browser

    Repeat in the phone's browser with the same account. Record where the two results differ.

Send your developer the step where the logout happened, the phone model, the Android version and the Set-Cookie header with the secret value removed. Never send a live session value in an email or chat, since it may let someone act as that user.

If you are preparing a store submission, remember that Google's reviewers also need to get in. Our guide to app access instructions covers what to give them.

Frequently asked questions

Why does my app log me out every time I close it?
Check whether the sign-in cookie has Expires or Max-Age. Without either it is a session cookie, which is removed when the client shuts down. Also ask your developer whether the app clears cookies at launch or exit.
Why do I stay logged in on Chrome but not in the app?
The app uses Android WebView with its own cookie handling. MDN notes that many browsers restore sessions, including session cookies, and WebView apps targeting Android 5.0 or later disallow third-party cookies by default.
Does Android WebView save cookies?
Android's CookieManager reference says WebView accepts cookies by default, and it provides a flush method to make sure cookies are written to persistent storage. Session cookies have no expiry date, so do not rely on them to last.
How long should a login cookie last in an app?
That is a security decision for your site, not a number Android sets. Pick a lifetime that suits the data behind the login, set it with Max-Age or Expires, and check that your server's session lasts as long as the cookie.
Is staying logged in the same as Google Play's zero-tap sign-in?
No. This article is about keeping a session on the same phone. Zero-tap sign-in concerns signing users in again on a new device and has its own requirements.