Beta

Create a tenant

A new tenant starts with its own users, OAuth settings, audit history and logs. You are its first Tenant Admin.

Establishing an application session

A validated sign-in is evidence about one moment. To keep a person signed in from one request to the next, the relying party starts a session of its own, with a fresh identifier, its own lifetimes and a record of what later decisions will need.

After validation

All domains, identifiers, and tokens in these examples are fictional, and the session identifiers are readable stand-ins for unpredictable random values.

On 1 October, a few days after linking her photo account, Ava opens collage.example to start a new collage. The collage app asks her to sign in, and she chooses Continue with your photo account. The photo service authenticates her at 08:59:45, and by 09:00:02 the collage app has exchanged demo-code-12, validated the ID token against demo-nonce-3, and found account 8812 through her photo identity.

The sign-in is complete, but nothing yet connects Ava's next click to it. The ID token is evidence that the photo service authenticated her a few seconds ago. Carrying that result from one request to the next is the collage app's own job, and it is the job Staying signed in described: a session.

Ava's browser already had a collage app session before she chose Continue. It was an anonymous one, created when she arrived, and it held the pending sign-in: state, nonce, PKCE verifier and the page she was on.

Cookie: __Host-collage-session=demo-session-30

That session carried the attempt out to the photo service and back, so it is tempting to mark it as signed in when the callback succeeds. Staying signed in explained why that is a mistake. If an attacker had planted demo-session-30 in Ava's browser, keeping the identifier would give them her account the moment she signed in. The collage app finishes in a fixed order instead:

  1. Take the return page from the pending sign-in, then delete the pending sign-in so its state and nonce can never be used again.
  2. Create a new session for account 8812 with a new random identifier, and invalidate demo-session-30 on the server.
  3. Send the browser to the return page with the new session cookie.

The response to the callback carries the new cookie and the redirect together:

HTTP/1.1 302 Found
Location: /collages/new
Set-Cookie: __Host-collage-session=demo-session-31; Path=/; Secure; HttpOnly; SameSite=Lax

The cookie has the attributes Staying signed in introduced, and it holds only an identifier. The ID token, the claims, and the account number all stay on the server.

The Location header deserves its own check. Ava was on /collages/new when the collage app asked her to sign in, and the app recorded that path in the pending sign-in when she chose Continue. It does not take the destination from the callback's address, or from a parameter someone could add to a sign-in link. An app that redirected wherever it was told could be used to send people from a genuine sign-in straight to a look-alike page that asks for their card details. The recorded value is checked as well: resolved against https://collage.example, it must keep that origin, which rules out values such as //attacker.example. Anything else falls back to the account home page.

Keeps the anonymous session

Cookie before
demo-session-30
Cookie after
demo-session-30
A planted identifier
Now opens Ava's account
Pending sign-in
Left in place
Return page from
The request

Fixation and an open redirect

Starts a new session

Cookie before
demo-session-30
Cookie after
demo-session-31
A planted identifier
Invalidated on the server
Pending sign-in
Deleted, used once
Return page from
The recorded path

Back to /collages/new, signed in

The ID token, the claims, and the account number all stay on the server.

Two ways to finish Ava's sign-in. Keeping the anonymous session hands a planted identifier her account; a new session and a recorded return page do not.

Three different lifetimes

At 09:00:02, three different things could each be described as Ava being signed in. Each has its own clock, and each is controlled by a different party:

WhatWhere it livesBeganEnds
The photo service's sessionA cookie for auth.photos.example that only the photo service can read08:59:45, when Ava authenticatedWhen the photo service's own policy says, possibly weeks later
The collage app's sessiondemo-session-31, recorded on the collage app's server09:00:02After two hours without activity, or seven days at most, under the collage app's policy
The ID tokenThe collage app's server, as evidence of one sign-inIssued at 09:00:00Accepted only until 09:05:00, its exp

The ID token's five minutes cause the most confusion. They limit how long the collage app may accept this token as evidence of this sign-in, which it did at 09:00:02. They say nothing about how long Ava stays signed in. An app that ended her session at 09:05 would sign everyone out after five minutes. The collage app's session timeouts are its own decision, based on what it protects, as Staying signed in described.

The two sessions are just as independent of each other. The collage app can't see the photo service's session, and the photo service can't see the app's. If Ava signs out of the collage app at 09:30, her photo service session continues, so choosing Continue with your photo account again may sign her straight back in without being asked for anything. That is single sign-on working as designed, though it can look as if signing out failed. Signing out of the photo service, in turn, leaves the collage app session running. The Logout and session coordination lessons look at how an app and its provider can tell each other when a session ends.

There is one more clock in the sign-in. The access token, demo-access-token-12, lasted ten minutes, and the collage app used it once to fetch Ava's profile from UserInfo. It has no further use for it, so it is not kept at all.

What the session records

The session record on the collage app's server holds what the app will need later, taken from the validated ID token rather than from anything the browser sends:

Session demo-session-31
  Account:                 8812
  Signed in with:          https://auth.photos.example, subject user-2048
  Authenticated at:        2026-10-01 08:59:45 UTC   (auth_time)
  Authentication context:  none in this ID token     (acr)
  Provider session:        none in this ID token     (sid)
  ID token:                kept for a later logout request
  Created:                 2026-10-01 09:00:02 UTC
  Last activity:           2026-10-01 09:00:02 UTC
  Idle deadline:           2026-10-01 11:00:02 UTC
  Absolute deadline:       2026-10-08 09:00:02 UTC

The account is what every later request is authorized against. Signed in with records which identity opened the session, which matters once an account has several. If Ava removes a link, as Linking accounts described, the app can find and end the sessions that link opened.

Authenticated at is the ID token's auth_time, not the session's creation time, and the two can be far apart. Here they are seventeen seconds apart, because the photo service had just asked Ava to authenticate. If she had signed in to the photo service the evening before, it could have answered this request from that session without asking her anything, and auth_time would say the evening before, even though the collage app session began at 09:00:02. When the app later wants a recent sign-in before changing her delivery address, this is the value it compares with the clock. Session age and reauthentication follows that check.

The authentication context is empty because the collage app didn't ask for one and the photo service didn't include an acr claim, a value naming how strongly the provider authenticated the person. When a provider reports one, the session keeps it, so a later decision can check how Ava signed in without asking again. Authentication context and methods explains what those values mean and who defines them.

The provider session is empty too. A provider that sends logout notifications can include a sid claim in the ID token, naming its own session for this sign-in. The collage app stores it so that a later notice saying that session has ended can find the matching app session. Registering for a provider's notices is covered in Local logout and provider sessions, and the claim appears there.

The ID token itself is kept on the server, never in a cookie or a page, for one reason. When Ava signs out, the app can send it back to the photo service as a hint about which sign-in is ending, which RP-initiated logout describes. It is not read again to decide who Ava is. The session record already says that.

The timestamps enforce the idle and absolute timeouts. The idle deadline moves forward with each request, and the absolute deadline does not. When either passes, the session ends, whatever is happening at the photo service.

Check your understanding

Try these questions before moving on. If an answer isn't right, use the feedback and try again.

The ID token from Ava's sign-in expires at 09:05. At 09:06 she is still choosing photos for a collage. What should the collage app do? 1 of 3

Choose one answer.

After a successful sign-in, where should the collage app take the address it redirects Ava's browser to? 2 of 3

Choose one answer.

Ava's browser already had an anonymous collage app session holding her pending sign-in. The callback succeeds. What should the app do with that session? 3 of 3

Choose one answer.

Try it in the Lab

We value your privacy

We use cookies and similar technologies to enhance your browsing experience, and analytics to understand our traffic. By clicking "Allow all", you consent to optional analytics. Cookie Policy

Learn identity