> For the complete documentation index, see [llms.txt](https://docs.serverlessapigateway.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.serverlessapigateway.com/glossary/s/session.md).

# Session

A session is a semi-permanent state maintained between a client and server across multiple requests. Since HTTP is a stateless protocol, sessions provide a mechanism to track user identity and state across sequential interactions. When a user logs in, a session is created on the server and a session identifier (typically stored in a cookie) is sent to the client.

Session management approaches include server-side sessions (state stored in server memory or a database, referenced by a session ID), client-side sessions (state encoded in a cookie or token, such as JWT), and hybrid approaches. Server-side sessions provide more control but require shared storage in distributed systems. Client-side tokens are stateless and scale more easily.

In API and serverless architectures, stateless authentication mechanisms like JWT tokens are generally preferred over server-side sessions because serverless functions are ephemeral and do not maintain local state between invocations. API gateways can validate session tokens or JWTs on behalf of backend services, centralizing session verification and reducing the burden on individual services.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.serverlessapigateway.com/glossary/s/session.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
