Empower growth and innovation with the latest Mobile App insights

The user opens the points mall in the app and has to log in again even though the native app is still logged in. Is the web side not connected?

Nov 11, 2026 Read: 44

In most cases, this is not an H5 login bug. The native app and the WebView each maintain their own login state, and the missing step is credential handoff. The native app stores credentials in Keychain, Keystore, or an app private directory, while H5 recognizes Cookies and localStorage under its own domain. By default, the two sides do not communicate. As a result, the home page and the 'Me' page work normally, but when the user taps into an operations-configured points mall or a customer service page provided by an external supplier, the API returns unauthorized and the page shows a login prompt. Based on common 2026 delivery situations, whenever H5 includes identity-bearing actions such as checking orders, claiming coupons, or submitting forms, this chain must be completed; otherwise, support tickets and conversion loss start here.

Why does H5 ask for a second login when the native app is still logged in

The typical feature of this problem is 'native works, H5 drops login,' and it often reproduces only at specific entry points: direct share links, direct notification bar links, and third-party supplier pages. The causes basically fall into the following areas and can be checked in order.

  • Injection timing is too late: H5 is already sending first-screen requests, and the credential is written only after the page starts loading, so the first screen is often in a logged-out state;
  • Domain mismatch: Cookies take effect by Domain. If they are written on domain a but H5 runs on domain b, they are not carried over, and cross-domain requests may also be blocked by SameSite policy;
  • Platform differences: iOS WKWebView does not share cookie storage with native, and Android WebView has its own profile, which may be cleared after a cold start or cache clearing;
  • Expiry not synchronized: The native app silently renews to a new credential, but no one updates the old one in H5;
  • Logout not linked: The native app logs out, but the H5 Cookie remains, and a refresh makes it 'alive' again.

The priority check can be simplified to one step: first reproduce once each from direct share links and direct notification bar links. If entering from the 'Me' page works but direct entry from external entry points loses login, it can basically be judged as an injection timing or domain issue, and there is no need to dig into the H5 business code first.

Credential handoff from native to H5: several approaches and cost comparison

None of these approaches wins universally. The choice depends on who maintains the H5, whether cross-domain is needed, and whether it contains money and personal information. Based on common 2026 project situations, it is advisable to evaluate each one before deciding.

  1. Put the token directly in URL parameters: This is easy for the front end to change, but the credential enters access logs, Referer headers, and links forwarded by users. It is suitable for internal low-sensitivity pages, not for long-term credentials.
  2. Inject Cookie or localStorage through WebView: This is the mainstream approach. The key is to inject before page load and align Domain, Path, Secure, and SameSite with the H5 domain.
  3. Exchange a one-time ticket for a session on the server: The native app puts a short-lived ticket into the link, and the H5 first screen uses it to exchange for a formal session. The ticket is consumed once and expires within tens of seconds. The change effort is one level higher, and security is one level higher. It is more suitable when payments, invoices, or personal information are involved.
  4. Fetch credentials on demand through JSBridge: H5 does not rely on Cookies and fetches the current credential through the bridge before each request. It is suitable for in-house single-page applications, not for third-party black-box H5.

Laying out the four dimensions for comparison makes the choice much clearer:

  • Security: One-time ticket and bridge are better than Cookie injection, and Cookie injection is better than putting a plaintext token in the link;
  • Change effort (experience range): Pure parameter approach is about 1-3 person-days, Cookie injection about 3-8 person-days, and ticket exchange about 5-15 person-days, depending on how many APIs need changes;
  • Cross-domain adaptability: The bridge approach has broader adaptability, while Cookie injection is clearly limited by Domain;
  • Expiry and logout linkage: Only solutions that land on a unified server-side session make this naturally easier to achieve.

In delivery: implementation when the budget is tight and the third-party page will only accept one extra parameter

In small-budget projects, a more common combination is: the cycle is around two weeks, the points mall page is provided by an external supplier, and the supplier only agrees to add one parameter to the link. In this case, a realistic implementation is to use a short-lived ticket, compress its validity to tens of seconds, make it one-time consumption, and fall back to a re-login page instead of a blank screen when ticket exchange fails. The cost is an extra round of API interaction, and integration and edge-case testing usually take 2-4 extra days (typical range). You also need to specifically test the path 'entering again after the ticket expires.' In this type of delivery, we put 'whether the first screen can directly carry the login state' near the top of the integration checklist, because rework here involves the native app, H5, and the server side.

Another recurring situation is that in older projects, a new WebView instance is created every time it opens, and credential injection is written after page load completes. The symptom is that the first screen always prompts login, and after the user logs in it returns to normal, which looks intermittent. The approach is to move injection before loading and make the H5 first screen wait for a ready event once. The change itself is not large, but if it is not run through before release, the direct share link and direct notification bar link entry points will go live with the problem.

When it is worth doing and when it can wait

Whether to invest can be judged by a very narrow criterion: does the H5 contain actions that cannot be completed without identity?

  • The H5 needs to check orders, claim coupons, submit forms, or initiate customer service tickets;
  • The same H5 needs to serve the App, mini-programs, and browsers at the same time, with multiple platforms sharing one session;
  • Operations changes pages frequently, and the native app does not want to release a new version every time.

Conversely, for static campaign pages for display only, read-only help documents, and brand promotion pages, users can finish viewing without identity. Forcing login checks would block people at the door and cause conversion to drop first. These pages do not need a full solution. For projects with only one or two H5 pages and a tight budget, using JSBridge to fetch the nickname and avatar once when needed is usually more cost-effective than building an SSO system. When no money or personal information is involved at all, accepting the experience of 'logging in again each time' and saving the cost for more critical flows is also a reasonable choice.

Acceptance criteria: what counts as properly connected

A qualified standard is not 'login works when clicked,' but that several paths can all close. It is recommended to go through them one by one; if any one fails, it is not done.

  • After a cold start, going directly from the notification bar or share link to an H5 secondary page does not trigger a second login;
  • After the credential expires, requests within H5 can renew automatically, and the user sees a normal page instead of a login popup;
  • After the native app logs out, H5 becomes invalid on refresh, and there is no 'logged out but can still view orders';
  • If the user actively logs out within H5, returning to the native app is also in a logged-out state;
  • After switching to the background for around half an hour and returning, the user remains online (experience range; actual depends on your own credential validity period);
  • Test weak network, repeated back navigation, and manual cache clearing once each.

A typical counterexample: the team only tested entry from the 'Me' page once and then released, without testing direct share links or direct notification bar links. These two entry points have no preceding native page, which makes them more likely to expose injection timing problems.

FAQ

After logging in on H5, returning to the native page requires another login. Is the direction reversed?

The direction is not aligned. Credentials should be sent one-way from native to H5, and after H5 login succeeds, it should call back to refresh the native state. Only when both directions have callbacks will they avoid logging in separately.

In the same version, Android does not require re-login but iPhone keeps losing login. Which layer is the problem?

Mostly the Cookie storage layer. WKWebView does not share cookie storage with native, and is stricter about third-party cookies. Injection must explicitly write into the cookie store and complete before the page starts loading.

What are the practical consequences of putting the token directly in the H5 link to save effort?

The credential enters access logs, Referer headers, and links forwarded by users. Once the link is forwarded to a group chat, it is equivalent to exposing a long-term identity. It is recommended to switch to a short-lived one-time ticket.

If the user manually clears the app cache and H5 loses login, does that count as a bug?

It is an acceptable result, but you need to distinguish whether what was cleared is regenerable cache or login state. Cleanup logic should only touch images and temporary files. If credentials are cleared too, inform users in advance and perform silent re-login.

If there are only one or two H5 pages, is a full solution still needed?

Not necessarily. When pages are display-only and do not involve money or personal information, using JSBridge to fetch the nickname once when needed is enough. Wait until actions such as placing orders or issuing invoices appear before adding the credential chain.


Before implementation, confirm three things clearly: who maintains the H5, whether it involves money and personal information actions, and how long credentials are valid. The answers determine whether to use Cookie injection or ticket exchange. If it is only page display, do not make a big effort for login state. If users need to place orders or issue invoices in H5, spending a few days to make the credential chain solid is usually much more cost-effective than repeatedly explaining after launch why they need to log in again.

Interested in this topic?
10-year tech team — reference proposal within 24 hours
Obtain Proposal
Are you ready?
Then reach out to us!
+86-13370032918
Discover more services, feel free to contact us anytime.
Please fill in your requirements
What services would you like us to provide for you?
Your Budget
ct.
Our WeChat
Professional technical solutions
Phone
+86-13370032918 (Manager Jin)
The phone is busy or unavailable; feel free to add me on WeChat.
E-mail
349077570@qq.com
Submitted successfully
Thank you for your trust. We will contact you soon!
Recommended projects for you