Written by Technical Team | Last updated 06.01.2026 | 14 minute read
Clinical web applications live in a world of competing pressures: clinicians need fast, uninterrupted access to patient information, while organisations must meet stringent security expectations around identity, access, auditability and data protection. NHS CIS2 (Care Identity Service 2) is designed to help by providing modern authentication options for health and care professionals in England, built around OpenID Connect and OAuth 2.0 patterns. But integrating CIS2 is only half the job. The other half—often the part that determines whether an application feels “clinical-grade” or frustrating—is session management.
Session management is where security and usability collide: how long a user stays signed in, how you deal with token expiry, how you handle role changes, how you prevent session hijacking, and how you gracefully recover when the network drops mid-consultation. Get it right and clinicians barely notice it’s there. Get it wrong and you end up with workflow breakage, unsafe workarounds, increased support tickets, and risk exposure.
This article goes deep on how to design secure, resilient session management for NHS CIS2-integrated clinical web applications. The focus is practical: architecture choices, token and session lifecycles, role and RBAC handling, and the operational realities of busy care settings where “secure” must also be “usable under pressure”.
NHS CIS2 is an authentication service that supports multiple authenticators beyond traditional smartcards—enabling organisations to modernise access while keeping the identity assurance model and clinical governance expectations intact. From an application perspective, CIS2 commonly shows up as an OpenID Connect identity provider, issuing ID tokens (for identity), access tokens (for calling protected resources), and refresh tokens (to obtain new access tokens without prompting the user to authenticate again).
This token-based approach is a major shift from older “long-lived session cookie” thinking. Tokens have explicit lifetimes and are meant to be rotated. That’s good for security, but it forces applications to be deliberate about the session lifecycle. In clinical contexts, this is not academic. If a token expires at the wrong time, a clinician may lose access mid-task; if your app re-authenticates too aggressively, it can become unusable in high-throughput environments; and if you overcompensate by extending sessions beyond sensible limits, you increase exposure in busy shared spaces.
It helps to distinguish three different “sessions” that can exist at the same time:
A secure design accepts that these won’t always align neatly. Your app session might continue (with read-only UI and preserved work) even when API access is temporarily unavailable. Or the CIS2 session might still exist while your app session has timed out due to inactivity. Good session management is the discipline of controlling how these states interact so clinicians get continuity without sacrificing security.
Finally, remember that clinical applications rarely operate in ideal conditions. Some users roam between wards, some work on shared devices, some are interrupted constantly, and some spend long periods reading rather than clicking. Session management must be designed for real behaviour, not best-case behaviour.
A robust CIS2 integration begins with treating OpenID Connect as a protocol you implement precisely, not approximately. The single biggest mistake teams make is assuming “we’ve got login working” equals “we’re production-ready”. In reality, production readiness is about what happens after login: token expiry, refresh, logout, device switching, concurrency, and error recovery.
A good mental model is: the ID token is not your session, and the access token is not your long-term credential. The ID token is a signed statement about the authentication event and user identity; the access token is a short-lived authorisation artefact intended to be presented to protected resources. Your application session should be an internal construct that can survive transient failures, while never storing more token material than necessary.
In CIS2 patterns, access tokens are typically short-lived (commonly minutes), while ID tokens tend to have a longer but still bounded lifetime (commonly around an hour). Refresh tokens exist to avoid repeatedly interrupting clinicians with re-auth prompts, but they come with rules: they can be rotated and may be single-use, meaning you must handle refresh carefully to avoid token reuse errors and accidental lockouts.
This shapes how you build your system:
The aim is to keep clinicians working without constant prompts, while ensuring credentials rotate appropriately and failures are recoverable. A well-behaved strategy looks like this:
When refresh fails, your user experience should be calm and clinical: preserve work, explain what action is needed, and provide a single obvious path to restore access.
Many CIS2 implementations stumble on predictable issues:
If you design your authentication flow with these realities in mind, session management becomes something you can reason about and test, rather than a set of edge cases discovered in production.
Session management for CIS2-integrated clinical web apps is best approached as a set of explicit policies. The goal is to create a session that is secure by default, responsive to risk, and still aligned with clinical workflow.
The first policy question is: what counts as “active use”? In a clinical UI, activity is not just clicking buttons. A clinician may be reading a long discharge summary, comparing results, or speaking to a patient while the screen is open. If your session times out purely on click events, you’ll log people out in the middle of care. If you never time out, you increase risk on shared devices.
A balanced approach uses both inactivity measures and absolute limits. Inactivity limits reduce risk when a device is left unattended; absolute limits ensure sessions don’t last indefinitely even with periodic activity.
The second policy question is: what happens when a session “expires”? Expiry should not equal data loss. Clinical users must be able to resume without re-entering extensive information, and the system should encourage safe behaviour rather than punishing the user with harsh resets.
Here are session controls that consistently work well in CIS2 clinical integrations:
Some environments still use smartcards and may rely on an identity agent for parts of the workflow, including role selection behaviour in certain setups. In these environments, physical card removal or authenticator changes can terminate sessions unexpectedly. Your application must assume that upstream authentication state can vanish at any moment. That means your UI should be resilient: if token refresh fails due to an upstream session ending, you move into a safe locked state rather than showing cryptic errors.
Alternative authenticators (such as platform authenticators or security keys) often produce a smoother experience, but they don’t remove the need for robust session design. They simply change the shape of re-auth events: instead of “insert smartcard and type PIN”, the user might approve a prompt or use biometrics. Your session flow should be agnostic to the authenticator and only care about the resulting security state.
For clinical sessions, two properties matter hugely:
You can meet these properties without destroying usability, but only if you treat them as design requirements rather than afterthoughts.
In NHS environments, identity is not enough. Access is shaped by RBAC (role-based access control), organisation context, and sometimes fine-grained application permissions. CIS2 can provide RBAC-related information via scopes and claims, and role selection can occur either via an external component (such as an identity agent in some setups) or within CIS2-supported role selection flows. The key point for session management is that a user’s effective permissions can change depending on the selected role, and your application must reflect that safely.
A common design mistake is to treat RBAC context as “just another user attribute” and cache it lazily. In clinical systems, role context is not a cosmetic preference; it’s a security boundary. Your session needs to know: which role is active, what organisation context is active, and what that means for permitted actions.
A clinician should always be able to answer: “Which role am I currently using in this application?” If the role changes, the UI should make it clear that permissions may have changed. This is both a safety feature and a support feature: it prevents confusion when functions appear or disappear.
In many applications, role context is decided once at login and never revisited. That can be fine, but you need a clean approach for situations where role change is required—for example, when a user needs to perform a privileged action that is not permitted under their current role. The worst solution is to force a complete logout and discard work. The best solution is to support a controlled role change that preserves user context while re-establishing authorisation under the new role.
Think of RBAC as a “policy input” rather than a “policy outcome”. CIS2 can provide role information and identifiers; your app should translate that into application permissions through a policy layer you control. This gives you flexibility and safety:
Once the session is established, store the effective authorisation context in the server-side session (or your secure session store) and treat it as authoritative for the duration of that session. If the user changes role, you create a new authorisation context and—crucially—you should consider regenerating session identifiers to reduce risk.
Not all authentication methods populate role-related claims in the same way, and not all users have a single neat role. Many clinicians have multiple roles across organisations, and they may switch between them in a day. This is where session management must be both strict and forgiving: strict about permission boundaries, forgiving about user experience.
Here are patterns that help:
To make these patterns actionable without overwhelming the UI, implement role and organisation context as first-class session concepts, not hidden technical details.
When teams struggle with CIS2 session management, it’s rarely because they don’t understand tokens. It’s because they haven’t turned requirements into repeatable engineering decisions: where state lives, how refresh is coordinated, how failures are handled, and what is logged for audit without leaking secrets.
This is where architecture matters. A single-page application that stores tokens in the browser will have different risks and mitigations compared with a server-rendered app or a BFF model. The best choice depends on your product constraints, but the session goals remain consistent: minimise token exposure, reduce clinician interruptions, and make failures safe and recoverable.
A strong baseline for many clinical web applications is:
This model reduces XSS blast radius and makes multi-tab refresh coordination easier. It also creates a clean place to implement “locked session” behaviour when re-authentication is needed.
Below is a practical checklist you can use to assess whether your CIS2 integration is genuinely production-ready from a session management perspective:
The final step is to test session management the way clinicians will actually use it: multiple tabs, unstable Wi-Fi, device sleep/wake cycles, interruptions, and rapid user switching on shared workstations. If your application behaves predictably under those conditions—locking safely, recovering smoothly, and never losing data unnecessarily—you’ve achieved the real goal of CIS2 session management: security that supports care, rather than security that gets in the way.
A CIS2 integration is not complete when a user can sign in. It’s complete when the session behaves safely and predictably across an entire shift: when tokens expire quietly in the background, when role context is clear, when locking protects patients and staff without punishing normal clinical behaviour, and when the application remains resilient even when the identity layer or network doesn’t. Treat session management as a core clinical feature—because in practice, it is.
Is your team looking for help with NHS CIS2 integration? Click the button below.
Get in touch