Skip to content
AI-powered appsNewChat, vision, voice, generationBookings & schedulingAppointments that book themselvesShops & sellingA storefront in every pocketClient & businessRun the operation from one placeCommunities & clubsA home that is not a group chat
Health & wellnessHabits, tracking and calmGames2D, 3D and multiplayerPersonal & toolsThe tool you wish existedInternal toolsThe tool ops never had time for
See all use cases
ArcadeNewPricingSecurity
EngineThe game engine and World EditorHow it worksFrom one sentence to a live productDocsGuides for building and publishingBlogStories, guides and newsChangelogWhat shipped latelyStatusUptime of every serviceSupportGet help from the team
AI-powered appsBookings & schedulingShops & sellingClient & businessCommunities & clubsHealth & wellnessGamesPersonal & toolsInternal tools
See all use cases
ArcadeNewPricingSecurity
EngineHow it worksDocsBlogChangelogStatusSupport
Language
Blog
GlossaryNovember 22, 20263 min read

What are sessions and cookies?

Websites forget you between every click unless something reminds them. Sessions and cookies are that reminder: a coat check ticket for the web, with a few flags that decide how safe it is.

Startbase Team
Editorial ink illustration of a coat check counter with a numbered ticket, the ticket in ember orange

Key takeaways

  • HTTP has no memory; a session is the server-side or token-based record that you are signed in, and a cookie is one way to carry it.
  • Cookie flags matter: HttpOnly blocks page scripts, Secure requires HTTPS, SameSite limits cross-site sending.
  • Session length is a product decision: a banking app might end sessions after 15 idle minutes, a game might keep players signed in for weeks.

A session is an app's memory that you are signed in across many separate requests, and a cookie is a small piece of text a website asks your browser to store and send back on every later visit. Cookies are the classic way to carry a session, though not the only one. Without either, a website would forget who you are the moment you clicked to the next page.

An everyday example: the coat check

You hand over your coat and get ticket number 57. You do not tell the attendant your name each time you pass; you show the ticket and they know which coat is yours. On the web, HTTP is the forgetful attendant: each request arrives with no memory of the last. After you sign in, the server makes a session (the coat on the hook, with your user ID and when it expires) and gives the browser a ticket in a cookie, like `session_id=8f3a...`. The browser shows that ticket automatically with every request to the same site.

Two ways apps keep sessions

  • Server sessions: the server keeps a table of sessions and the cookie holds only a random ID. Signing someone out means deleting their row, effective immediately.
  • Token sessions: after sign-in, the client holds a signed token such as a JWT plus a refresh token, and sends it with each request. The server verifies the signature instead of looking up a row. Many single-page apps and mobile apps work this way, storing tokens in browser storage or the phone's secure storage rather than in a cookie.

The cookie settings that matter

  • HttpOnly: page scripts cannot read the cookie, so injected code cannot steal the session.
  • Secure: the cookie is only sent over HTTPS.
  • SameSite: `Lax` (a sensible default) or `Strict` stops the browser sending the cookie on most requests started by other sites, which blocks a class of attacks called cross-site request forgery. `None` allows it and requires Secure.
  • Expires or Max-Age: without one, the cookie disappears when the browser closes.

How long a session should last is a product choice. Reasonable starting points: 15 to 30 idle minutes for money or health data, around 30 days with refresh for a social or productivity app, longer for a casual game where being signed out is just annoying.

Why it matters when building with Startbase

When Startbase Cloud handles sign-in, the auth library manages the session for you: tokens, renewal and sign-out. Your part is choosing behavior. The Startbase security practices checklist is worth following: use built-in session management for token handling, redirect on expired sessions but always re-validate on the server, and use the frontend's signed-in state only for what the screen shows. If you add analytics or marketing tools that set their own cookies, your privacy policy and, for visitors in the EU, a consent banner come into play.

Keep users signed in on this device for 30 days unless they sign out. If their session expires while they are filling in a form, save the draft, send them to sign in, and bring them back to the same form with the draft restored. Add a "Sign out of all devices" button in settings.

Common confusions

  • Not every cookie is a tracker. A session cookie that keeps you signed in is strictly necessary; third-party advertising cookies are the ones consent rules target.
  • Clearing cookies signs you out, which is why "try clearing cookies" fixes stuck sign-in states.
  • Browser storage is not a cookie. localStorage is never sent to the server automatically and any script on the page can read it.

Frequently asked questions

Why do I get signed out when I switch browsers?

Cookies and browser storage belong to one browser on one device. A new browser has no ticket to show, so you sign in again and get a new session.

Do mobile apps use cookies?

Usually not for sign-in. Native and React Native apps typically keep tokens in the phone's secure storage and send them in a request header.

On this page

  • An everyday example: the coat check
  • Two ways apps keep sessions
  • The cookie settings that matter
  • Why it matters when building with Startbase
  • Common confusions

Keep reading

More in Glossary
Editorial ink illustration of a hand-cranked music box drum plucking a metal comb, the crank handle in ember orange
GlossaryNovember 22, 2026

What is a game loop?

Every real-time game runs one repeating cycle: read input, update the world, draw it. Here is what that cycle looks like and why it decides how your game feels.

3 min read
Editorial ink illustration of a brass stopwatch beside a small wind-up toy car, the second hand in ember orange
GlossaryNovember 22, 2026

What is delta time?

Delta time is the number that keeps your game the same speed on every screen. Here is how to use it, where it breaks, and how to spot a game that forgot it.

3 min read

Read less. Ship more.

Everything in this post is one prompt away. Describe your app and watch it build.

Start building

Apps, games, backends and publishing from one conversation.

Product

  • Features
  • Use cases
  • Pricing
  • Changelog

Resources

  • Blog
  • Docs
  • Support
  • Status
  • Security

Contact

  • w@startbase.ai
  • X / Twitter
  • LinkedIn
  • Instagram

Legal

  • Terms
  • Privacy

© 2026 Startbase. All rights reserved.