Prompt
How do I support shared devices and cross-browser sign-in in a passwordless flow?
Latest observation
To support shared devices and cross-browser sign-in in a passwordless flow, design around one core principle:
The “login session” should be portable and recoverable, but the “proof” should happen on a trusted device or factor, not just in the current browser tab.
Here’s a practical way to structure it.
1) Use a central account, not a browser-bound identity
In passwordless systems, the user should authenticate to an account that lives on your backend, not to a browser profile.
- The browser only holds a session token/cookie after login.
- The actual identity is tied to:
- email/phone,
- passkey/WebAuthn credential,
- magic link,
- OTP,
- device approval, etc.
This lets users sign in from any browser while keeping account state consistent.
2) Support multiple authentication methods
For shared devices and cross-browser use, it helps to offer at least one of:
Strong option: Passkeys / WebAuthn
- Best for cross-browser and shared-device scenarios.
- Can work across devices if synced (depending on platform/provider).
- On a shared device, the user can authenticate with a platform authenticator, security key, or a synced passkey from their phone.
Backup options
- Email magic link
- One-time code via email/SMS
- Device approval via push notification
- Recovery codes
This reduces lockout when the user isn’t on their usual device.
3) Make sign-in “device-aware,” not device-dependent
For shared devices, never assume the device is trusted just because someone used it once.
Recommended pattern
After login:
- Create a session cookie
- Mark it as:
- persistent only if user opts in (“Remember this device”)
- otherwise session-only
- Give users visibility into active sessions/devices
On shared/public devices
Default to:
- short-lived sessions
- no “remember me”
- stronger re-authentication for sensitive actions
- automatic logout on browser close if appropriate
4) Add a trusted-device enrollment step
If you want smoother cross-browser sign-in, let users register trusted devices:
- User signs in on Device A
- User approves Device A as trusted
- Later, on Browser B or another device, you can:
- send a magic link to the user’s email,
- prompt approval from Device A,
- or use a passkey/security key.
This gives a good balance of usability and security.
5) Use cross-device login approval
A very user-friendly pattern:
- User enters email on Browser B
- Backend creates a login request
- User approves it from a trusted device already signed in
- Browser B receives a session
This works well for:
- shared computers,
- no-password environments,
- users switching browsers,
- enterprise or high-security scenarios.
6) Handle session continuity carefully
For cross-browser sign-in, sessions should be backend-managed and revocable.
Use:
- secure, HttpOnly cookies
- short access sessions
- refresh tokens or rolling sessions if needed
- session revocation on logout / security events
Important:
- Don’t store sensitive auth secrets in localStorage.
- Prefer cookie-based session management.
7) Make account recovery explicit
Passwordless systems need strong recovery paths, especially if the user loses access to their email/device.
Offer:
- backup email
- recovery codes
- verified phone as fallback
- support-assisted recovery for high-risk accounts
This is critical for shared-device users who may clear cookies or lose session state often.
8) Differentiate “shared” from “trusted”
A shared device should generally be treated as untrusted unless the user explicitly enrolls it.
You can implement:
- Trusted device: longer session, lower friction
- Shared/public device: limited session, stricter checks
- New browser/device: step-up verification required
9) Suggested UX flow
First sign-in
- User enters email
- Chooses one of:
- passkey
- email link
- OTP
- After success, optionally prompt:
- “Trust this device?”
- “Enable passkey for faster sign-in?”
Later sign-in from another browser
- User enters email
- System checks risk/device state
- If needed:
- send email magic link
- ask for passkey
- request approval from a trusted device
On a shared device
- default to temporary session
- do not prefill or auto-login after logout
- make sign-out clear and complete
10) Security best practices
- Use phishing-resistant auth where possible (passkeys > OTP)
- Bind sessions to server-side state so they can be revoked
- Rotate session identifiers after login
- Detect unusual login attempts and step up verification
- Limit sensitive actions with re-authentication
- Provide a device/session management page
A good practical recommendation
If you want the simplest robust solution:
- Primary auth: passkeys (WebAuthn)
- Fallback auth: email magic link
- Session model: secure server-side sessions with HttpOnly cookies
- Shared device behavior: short-lived, non-persistent sessions by default
- Cross-browser support: login via magic link or passkey on any browser
- Recovery: backup codes + account recovery flow
If you want, I can also sketch:
- a reference architecture,
- a sequence diagram for shared-device login,
- or a sample implementation for web apps using passkeys + magic links.
Brands