← Back to Can my app have its own users who sign in?
How do I choose how long people stay signed in to my app?
Short answer
Choose a time from 5 minutes to 14 days, put it in seconds in renewWindowSec, then build and publish your app again.
Before you start
Your app signs people in with an e-mail code, and is published at its pages.dev address with the connector or runs on an address the platform owner approved for it.
Words used here (2)
- GilbPlatform
- GilbPlatform is the service that keeps people's and organisations' data in vaults, each at its own web address.
- code unit
- A code unit is a ready piece of app code, such as a card or picker, kept in its own folder for apps to reuse.
Steps
Choose how long a person stays signed in.
Pick a time from 5 minutes up to 14 days; if you choose none, it is 14 days. Shorter is safer when people share a computer or phone; longer means fewer sign-ins.
More about this
In seconds: 5 minutes is 300, 1 hour 3600, 1 day 86400, 7 days 604800 and 14 days 1209600. The time is counted from the sign-in, and again from each renewal, when the app trades its renewal credential, a hidden secret, for a new token: each renewal moves the end to that time from then. A person who comes back after the end signs in again with a new code. If your AI builds the app under GilbPlatform's standards, it asks you this before it publishes and does not choose for you.
Put the time in your app's code, in seconds.
With the signin unit of GilbPlatformCode, GilbPlatform's library of ready-made code, version 0.2.7 or later, pass the time as renewWindowSec to SessionCredential; if you call GilbPlatform yourself, send renewWindowSec with renew true when you trade the code at verify-code.
More about this
The platform takes a whole number of at least 300; a number above 1209600 counts as 14 days. Under 300 it answers 400 renewWindowSec must be an integer of at least 300 seconds, and a fraction or text answers body/renewWindowSec must be integer; the code is not used up. The signin unit itself throws when the number is outside 300 to 1209600. The time is kept with each sign-in: a person already signed in keeps the time they signed in with until they sign in again. The signin unit is taken from GilbPlatform's code library, https://github.com/KaiGilb/GilbPlatformCode, folder units/signin; the answer How do I reuse app code units? shows how.
Publish the app again under the same name.
Build your folder again and publish it under the same name; publishing a site you already hold again works and uses no new site:
node ~/.gilb-connector.mjs publish --dir <built folder> --name <name>More about this
The answer How do I publish my app from the terminal? shows each step. People who sign in after that get the new time; people signed in before keep theirs until they sign in again.
Deeper
Also asked:
How do I set how long a sign-in lasts in my app? Choose a time from 5 minutes to 14 days, put it in seconds in renewWindowSec, then build and publish your app again; if you choose none, it is 14 days.
People stay signed in to your app for the time you choose, from 5 minutes up to 14 days, and 14 days if you choose none. GilbPlatform never allows longer than 14 days.
How it works. A person signs in once with a code sent to their e-mail. Your app gets a sign-in token and a renewal credential, a hidden secret, and trades the credential for a new token before the old one runs out. Each token lasts 7 days at most, and never past the end of the time you chose; since 12 November 2026 that holds for the first token too. With a time of 7 days or less, the token runs out at that end, so a renewal must come before it: a renewal after the end is refused. The platform accepts a renewal at any time before the end, so an app that renews when the person comes back counts the time from their last visit. The signin unit renews when its token has less than a minute left, or has run out, so with it the time counts from the sign-in or the last renewal, not from each visit.
Who gets it. Only a web app in a browser, on an address the platform owner approved; an app published at https://<name>.pages.dev with the connector is approved on its own. A site published as a website cannot sign people in. A phone app that sends no web origin gets no renewal: its sign-in lasts 7 days, then the person types a new code. GilbPlatform's own sites, such as GilbApp, keep their own sign-in.
Signing out. When your app sends POST https://id.gilb.com/base/auth/sign-out, the platform ends the sign-in made with that device's key, and its renewal stops working at once; it does not sign the person out of their other devices or of GilbPlatform's own apps.
Several tabs or devices. When the app renews, the credential it replaced is still accepted once for 60 seconds. After that, an old credential is treated as a stolen copy: the platform ends the sign-in, and the person signs in again. Let one tab renew at a time and keep the credential in one place; the signin unit does that for tabs in one browser. The answer Why must my app's users sign in again on every reload, or after a week? tells what else signs people out.
The Developer Guide, GilbPlatform's guide for people who build apps on it, has every request and answer in Dev.Guide.SignIn.StaySignedIn, https://appbuilder.gilb.com/base/e/06gwy4emx9ym93q17m0agvadnm (© 2026 Kai Gilb / GilbPlatform, CC BY 4.0). Its examples are marked Not yet verified on production. The answer How do I refresh a token? shows the calls.
This answer is written for a computer screen.
Source: GilbPlatform 0fc5a548 (https://id.gilb.com/version, read 13 November 2026): src/auth/renewable-sign-in.ts:81-84 (300 seconds shortest, 14 days longest), :90 (60 seconds), :204-207 (a sign-in at or past its end is expired), :519 (end = sign-in + window), :633-634 (an expired sign-in is refused), :665 (each renewal: end = now + the window kept with the sign-in); src/routes/email-auth.ts:115-118, :440-460 (renew, renewWindowSec; 400 renewWindowSec must be an integer of at least 300 seconds before the code is used; above 14 days capped; default 14 days; with a renewal the first token lasts no longer than the window), :309-316 (only an exact, approved, not first-party origin starts a renewal); src/auth/email-otc.ts:316-321, :482 (first token = min(7 days, window)); src/routes/renew-sign-in.ts:26-31, :140-148 (new token = min(7 days, what is left); 401 renewal refused); src/routes/sign-out.ts:1-40 (sign-out ends the device key and the renewal); src/routes/publish.ts:460-485 (an app's pages.dev origin approved on publish; none for a website). Revision 140ab2f0 (first token no longer outlasts the window) is in 0fc5a548. GilbPlatformCode units/signin (package @kaigilb/gilbplatformcode-signin 0.2.9), https://github.com/KaiGilb/GilbPlatformCode at 2d0b96c1, read 13 November 2026: src/session.ts:78 (EXPIRY_GUARD_MS 60 s), :81-84 (300 to 1209600), :333-337 (renewWindowSec, default 14 days, anything else throws), :497, :592 (renew true with the window), :830-833 (restore renews only a token inside the guard or expired), :1689-1700 (renew inside navigator.locks across tabs). Developer Guide (© 2026 Kai Gilb / GilbPlatform, CC BY 4.0), Dev.Guide.SignIn, https://appbuilder.gilb.com/base/e/06gkzpwhanxrh55sca1pdkxj88, read 13 November 2026: exhibits TokenLife, StaySignedIn (The window counts from the last renewal.; the 400 answers; "From revision 140ab2f0: the first token lasts no longer than the window you asked for."; 60 seconds; "An app built with the signin unit 0.2.7 or later passes renewWindowSec to SessionCredential"; every example Not yet verified on production). Standards read from GilbPlatform on 13 November 2026: Proc_v_i_c_PublishPagesDev (steps 1, 2 and 10: ask, 14 days longest and default, 300 shortest, the common values, shorter safer on shared devices, the AI does not choose; change it by building and publishing again), Standard Rule_Code_deployment (RuleDeployPagesDev: never longer than 14 days). Live help pages, sentences shared: How do I refresh a token?; How long do tokens last?; What happens when my AI asks if my app should go live?; How do I update my app after it is live?
For developers
curl
verify-code-request.sh
# From the Developer Guide, Dev.Guide.SignIn.StaySignedIn (© 2026 Kai Gilb / GilbPlatform, CC BY 4.0),
# with placeholders. renewWindowSec 86400 keeps the person signed in for 1 day.
curl -X POST https://id.gilb.com/base/auth/email/verify-code \
-H 'Origin: https://<name>.pages.dev' \
-H 'Content-Type: application/json' \
-d '{
"email": "<their e-mail address>",
"code": "<the 6-digit code>",
"dpopJwk": { "kty": "EC", "crv": "P-256", "x": "<x>", "y": "<y>" },
"renew": true,
"renewWindowSec": 86400
}'
Checked against GilbApp d529620.