# Check quietly whether a user is signed in

> Let an app find out, without showing any page, whether the user already has a session with the realm.

An app can sign a user in automatically when they're already signed in to the realm, and otherwise show its own
**Sign in** button. It starts a normal sign-in with `prompt=none`, and the realm never shows a page: the user sees
nothing, whatever the answer, and the app decides what to show next.

**Before you start:**

- **Who can do it:** the app's developer. There's nothing for a realm administrator to set.
- **Where:** in the app's own sign-in request.
- **First:** register the app for the browser sign-in, as in [Sign users in to a web app](../sign-in-web-app/) or
  [Sign users in to a single-page app](../single-page-app/).

## Check for a session

<Steps>

1. The app adds `prompt=none` to its usual sign-in request at `https://foobar.cvyuh.com/oauth2/authorize`.

2. It reads the answer at its return address:

   | The user… | The app receives |
   |---|---|
   | is signed in and has allowed this app | a code, as after any sign-in |
   | isn't signed in | `login_required` |
   | is signed in, but hasn't allowed this app what it asks | `consent_required` |

3. On a code, the app redeems it as usual. On `login_required` or `consent_required`, it shows its **Sign in** button,
   which starts a sign-in without `prompt=none`.

</Steps>

## Check it worked

Open the app in a browser that is signed in to the realm: it should sign you in with no page shown. In a private
window, it should get `login_required` and show its button.

## Troubleshooting

| Symptom | Cause | Fix |
|---|---|---|
| Always `login_required`, even when signed in | The browser doesn't send the realm's cookie to the app's frame or redirect, often a third-party cookie block in an embedded frame | Use a top-level redirect, not a hidden frame |
| `consent_required` for a user who allowed the app | The app asks for more scopes than they allowed, or for `offline_access`, which is asked every time | Ask for the scopes they allowed; leave `offline_access` for the interactive sign-in |

## Undo it

Stop sending `prompt=none`. Nothing changes in the realm.

## Other prompts

| `prompt=` | What it does |
|---|---|
| `none` | Never show a page, as above |
| `login` | Always ask the user to sign in again, even with a session: see [Ask users to sign in again](../../stronger-sign-in/ask-to-sign-in-again/) |
| `consent` | Always show the consent page, even if the user allowed this before |

## Related

- [Call the API](../../../../develop/api/): the conventions every call follows.
- [Apps and agents](../../../../develop/apps-and-agents/): every endpoint apps and agents call.
- [Authorization code with PKCE](../../../applications/single-sign-on/authorization-code/): the request `prompt` is part of.
- [Ask users to sign in again](../../stronger-sign-in/ask-to-sign-in-again/): `max_age`, `prompt=login` and hints.
