> For the complete documentation index, see [llms.txt](https://shipclojure.gitbook.io/shipclojure-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://shipclojure.gitbook.io/shipclojure-docs/decisions/001-cookie-sessions.md).

# 001 - Cookie Sessions

Date: 2024-06-5

Status: accepted

## Context

Initially I wanted ShipClojure to use JWT tokens and [refresh token rotation](https://auth0.com/docs/secure/tokens/refresh-tokens/refresh-token-rotation) but that turned out to be problematic especially when it comes to server rendering.

Another issue is that the Clojure community is more set on cookies. You can observe this from the strategies and auth packages already existent.

## Decision

Authentication will be done through a session cookie store, signed with a secret found in `system.md`. The secret is persistent so sessions aren't revoked every time we restart our server.

## Consequences

The code for access/refresh token logic will be deleted, however you can still find it in the history. [Here is the last working commit with refresh token logic](https://github.com/shipclojure/shipclojure/commit/4e25ea6a3d511537111071d18d42a6ac03b4c83b)

ShipClojure will make heavy use of cookies. The session will be accessible in the `:session` map from each `request` incoming to the server

One problem with this approach is that from user management, we cannot revoke a session. As a solution, we will implement a persistent session memory (redis or [persistent atom](https://github.com/jimpil/duratom)) that can be deleted.


---

# 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://shipclojure.gitbook.io/shipclojure-docs/decisions/001-cookie-sessions.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.
