Designing session and token lifetimes
One sign-in leaves several things behind, and each of them has its own lifetime: the application's session, the provider's session, an access token and a refresh token. This lesson follows Ava through a day with the printer to show how those lifetimes interact, what each one actually limits, and how the photo service chooses values for them on purpose.
Four clocks in one sign-in
At 09:00 Ava signs in to the printer with her photo service account, starts a photo book and leaves the tab open. At 09:10 the printer quietly gets a new access token. After lunch she comes back and the printer asks the photo service who she is, but she sees no sign-in page. At half past five it asks again, and this time she types her password. Nothing went wrong at any point. Ava met four separate clocks, each set by a different decision, and each ran out at a different time. All domains, accounts and tokens in these examples are fictional.
The first is the printer's own application session, the cookieA small value that a website asks the browser to store and send back with later matching requests. Cookies commonly carry a session identifier, so the site can recognize an ongoing sign-in without your password. that Establishing an application session described, which tells the printer's server that this browser belongs to Ava's account, user-2048. The second is the photo service's provider session, its own cookie on auth.photos.example, which lets it answer an authorizationDeciding whether a requested action is permitted, such as whether a signed-in account may delete a particular photo. Authentication says which account is asking; authorization decides what it can do. request without asking for her password. The third is the access token the printer sends to the photo APIAn application programming interface: a defined way for software to interact with a service. A web API offers endpoints where other programs send HTTP requests.. The fourth is the refresh token the printer's server uses to get new access tokens without involving Ava's browser at all.
| Clock | Held by | Lets someone | When it runs out |
|---|---|---|---|
| Application session | Ava's browser, as a printer cookie | Use the printer's pages as Ava | The printer sends her to the photo service |
| Provider session | Ava's browser, as a photo service cookie | Sign in to any connected application without a password | The photo service asks her to sign in |
| Access token | The printer's server | Call the photo API | The printer refreshes it |
| Refresh token | The printer's server | Get new access tokens with nobody present | The printer needs Ava to sign in again |
Each product ships with defaults for its own clock, and nothing makes those defaults agree with each other. Lifetime design is the job of setting all four on purpose, knowing how they interact.
Idle and absolute timeouts
Staying signed in introduced the two limits a session can have. An idle timeout ends it after a stretch with no activity, and each use starts that stretch again. An absolute timeout ends it a fixed time after it began, however busy it is. The printer gives its application session an hour idle and twelve hours absolute, so Ava's lunch break ended it, while a day of steady work would have run into the twelve hours instead.
The two protect against different things. The idle timeout covers the laptop left open in a coffee shop: nobody is using the session, so it ends soon. The absolute timeout covers a session somebody is using, perhaps not Ava, by putting a ceiling on how long anything that started with one sign-in can last. A session with only an idle timeout can run forever if something keeps touching it, and that something can be a stolen copy of the cookie.
Refresh tokens have the same pair under other names. Refresh tokens and rotation called them the idle lifetime, which slides forward with each refresh, and the absolute lifetime of the token family, counted from the approval that started it. Rotation replaces the token at each use, which keeps moving the idle deadline but never the absolute one. Access tokens usually have only an expiry, the exp claim, because they are short enough that an idle limit would add nothing.
How the layers depend on each other
The clocks are independent in the sense that matters most: when one runs out, the others keep running. Ava's day showed each case.
At 09:10 only the access token ran out, and the printer refreshed it from its server. At 13:05 the application session had gone idle, so the printer sent Ava's browser to the photo service, whose session was still alive, and she was back a moment later without seeing a page. At 17:30 the photo service's eight-hour session had passed its absolute limit, so the photo service asked for her password. The printer could only send her there. The decision to ask was the photo service's.
That dependence runs in one direction. A short application session leans on the provider session to bring people back quietly, so a printer with a ten-minute session and a photo service with an eight-hour session gives Ava eight hours of quiet returns, not ten minutes of security. If the printer wants a real password prompt after ten minutes, it has to ask for one, with the max_age parameter that the step-up section below returns to.
The reverse also holds: ending the provider session does not end the printer's session, or its refresh token. When Ava signs out at the photo service, the printer learns about it only if it listens for the logout tokenA signed JWT that an OpenID Provider sends directly to a relying party's server to say that a person's session at the provider has ended, naming them by sub, sid, or both. The relying party validates it like an ID token and ends its own matching session. that Back-channel logout described, and the refresh token stops working only if the photo service revokes it too. The NIST digital identity guidelines, SP 800-63B-4, describe federationAn arrangement that lets systems accept identity information from another trusted system, so an application can rely on a sign-in performed by a separate identity provider. the same way: the provider's session and the application's session are managed separately, and the application decides whether its own reauthentication rules are met.
So the useful question is never just how long a session lasts, but which clock actually bounds each kind of access. For the printer's background work the answer is the refresh token's absolute lifetime, not anything Ava's browser holds.
The revocation gap
Suppose the photo service locks Ava's account at 11:00 because she reports that someone else has been using it. The provider session ends at once, and the refresh token is revoked, so the printer's next refresh fails with invalid_grant and no new access tokens are issued. The access token the printer received at 10:55 is another matter. The photo API validates JWTA JSON Web Token: a compact token made of Base64url-encoded parts that carries claims and is usually signed. Anyone holding it can decode and read the claims, so the signature shows who issued it but hides nothing. access tokens locally, checking the signatureA value made with a private key that lets anyone holding the matching public key check that a message came from the key's holder and has not been changed. It proves origin and integrity; it does not hide the message. and expiry as Token formats and validation described, so it never asks the photo service about the account. It has no way to know about the lock, and it accepts that token until it expires at 11:05.
11:0011:00: the photo service locks Ava's account
Cookie on auth.photos.example
Ends at once
Held by the printer's server
Revoked
Next refresh fails with invalid_grant
Issued at 10:55
- Signature
- Valid
- exp
- 11:05
Accepted by the photo API until 11:05
The revocation gap: five minutes in which the lock has not reached the photo API.
The time between a decision to cut access and the moment access actually stops is the revocation gap. For a locally validated token it is the token's remaining lifetime. For a token the API checks with introspection, asking the photo service each time whether the token is still active, it is however long the API caches that answer. For an application session the gap is the session's own lifetime, unless a logout signal reaches the application sooner.
The gap is what an access token's lifetime really buys, so it is worth deciding per operation rather than per product. A useful way to do that is to sort operations into risk tiers:
| Tier | Example operations | Acceptable gap | How the API gets there |
|---|---|---|---|
| Low | Viewing albums, listing print sizes | Up to an hour | Local validation of tokens that last up to an hour |
| Medium | Ordering prints, changing a delivery address | About ten minutes | Local validation of ten-minute tokens |
| High | Sharing an album publicly, changing payout details, administration | Seconds | Introspection with little or no caching, or a fresh sign-in for the action |
Shortening every access token to a minute would close the gap everywhere, at the cost of a refresh request every minute from every client. Tiers let the cheap path serve the operations where a few minutes do not matter, and spend the expensive checks where they do.
Step-up windows
A session that is still valid says that someone signed in, perhaps hours ago. Some actions need to know that Ava, specifically, proved herself recently. When she changes the printer's delivery address, the printer asks the photo service for a sign-in no more than five minutes old with max_age=300, then checks the auth_time claim in the ID tokenIn OpenID Connect, a signed JWT from the provider, addressed to one client, saying which account authenticated, when, and in answer to which request. It reports a sign-in and is not used to call APIs. that comes back, the exchange Session age and reauthentication walked through. Asking for fresh proof before one sensitive action is often called step-up, and those five minutes are a step-up window: a lifetime for one kind of evidence, separate from every clock above.
Windows should be short and attached to the action, not to the session. Five minutes for a change of address, or zero for releasing a payment, makes sense. Extending the whole session because Ava stepped up once does not, because it turns a check for one action into a stronger session for everything that follows. A window can also ask for a particular method, as Requesting stronger authentication showed, so that a recent password does not satisfy an action that needs a recent passkeyA credential that your phone, computer or password manager creates for one website and keeps for you, unlocked with a fingerprint, face or PIN. Nothing you could type is sent, and it works only for the site it was made for, which helps it resist phishing..
The assurance levels in Authenticator assurance levels put outer limits on these choices. At AAL2, SP 800-63B-4 says the overall reauthentication limit should be no more than 24 hours and the inactivity limit no more than an hour. At AAL3 the overall limit is at most 12 hours and inactivity should be no more than 15 minutes. At AAL1 the overall limit should be no more than 30 days. These are ceilings for the session that carries that level, not targets.
Binding the session to the device
Every limit so far assumes the session cookie is a bearer credentialA token that works for whoever presents it: the API checks that the token is genuine and current, not who is holding it. That is why bearer tokens must be kept from being copied.: whoever holds it is treated as Ava. That is why lifetimes matter so much. Malware that copies cookies out of a browser gets a session that lasts as long as its absolute limit, from any computer.
The alternative is to tie the session to a key that never leaves Ava's device, so that a copy of the cookie alone is not enough. Device Bound Session Credentials, or DBSC, does this for browser sessions. When a session starts, the browser creates a key pairA private key and a public key generated together and mathematically linked. The private key creates signatures and the public key checks them, but the private key cannot practically be worked out from the public one., keeping the private keyThe half of a key pair that its owner keeps to themselves and uses to create signatures or decrypt data. Anyone who obtains it can act as its owner. in secure hardware where the device has it, and registers the public key with the site. The site then issues cookies that last only a few minutes and renews them only when the browser signs a fresh challenge with that private key. A copied cookie stops working within minutes, because the key needed to renew it cannot be copied out. DBSC is being standardized at the World Wide Web Consortium (W3C), the body that also publishes WebAuthn, and in 2026 it is generally available only in Chrome on Windows. A site must also implement registration and renewal on its own servers.
Binding changes how lifetimes are chosen rather than removing the need for them. A bound session can afford a longer absolute limit, because its short-lived cookies limit what a copy is worth. An unbound session in the same application, in a browser without DBSC, still needs the stricter values, so a site that adopts DBSC usually runs two sets of numbers side by side. Limiting what stolen access can do, in Identity security, sets binding beside the other ways of shrinking what a stolen credential is worth.
Choosing values
The photo service set lifetimes for three of its applications in one sitting, working through the same questions for each: who uses it and how often, what the worst action in it is, what revocation gap that action tolerates, and how often people will accept being asked to sign in.
| Clock | Phone app for customers | Printer integration | Staff administration console |
|---|---|---|---|
| Application session | Kept by the app while the refresh token lasts | 1 hour idle, 12 hours absolute (the printer's choice) | 15 minutes idle, 8 hours absolute |
| Provider session | 30 days, renewed by use on the phone | 8 hours absolute | 8 hours absolute, phishing-resistant sign-in |
| Access token | 15 minutes | 10 minutes | 5 minutes, checked by introspection |
| Refresh token | Rotated; 30 days idle, 180 days absolute | Rotated; 30 days idle, 90 days absolute | None: staff sign in again |
| Step-up window | 5 minutes for a new delivery address | 5 minutes for a new delivery address | Fresh passkey sign-in for role changes |
Each column follows from its answers. Customers open the phone app a few times a month and would abandon it if asked for a password each time, and the worst thing a stolen copy can do there is limited and visible to them, so the refresh token carries the long relationship and the access token stays short. The administration console can change other people's access, its users expect checks, and a stolen session there would cost far more, so it has no refresh token at all and checks every token with the photo service.
Two rules kept the table honest. Every value in a column had to be consistent with the others, which is why the console's 15-minute idle session is not undone by a long refresh token. And every number had to be one the photo service could explain to the person affected by it. A lifetime chosen because the product defaulted to it, or because a stricter number felt safer, tends to be the one people quietly work around.
Check your understanding
Try these questions before moving on. If an answer isn't right, use the feedback and try again.
Try it in the Lab
- Set the session and token clocks, then watch them run out separatelyGive the provider session an idle limit and lab-collage's tokens short lifetimes, then let the session go idle and see the refresh token keep working.