API Reference

Gorilla Sessions

Cookie and server-side session management for Go, with a pluggable registry of session stores.

Official Documentation ↗
CompatibilityThis documentation covers version v1.2. Check the official docs for the latest API surface.

Installation

gogo get github.com/gorilla/sessions

Methods

Gorilla Sessions stores session values either in signed cookies or in a server-side store.

Key Features

  • Cookie and filesystem stores
  • Signed and encrypted cookies
  • Flash messages and per-request session

Usage Notes

Pin a version and check the official docs for the API surface you depend on before upgrading.

Errors

The following points are quoted verbatim from the official documentation. 来源:https://pkg.go.dev/github.com/gorilla/sessions · 取证方式:HTTP GET 官方 README/文档页(HTML 去标签) · 抓取时间:2026-11-07T13:50:03.878Z. Any error type, throw condition or recovery step not stated there is left unspecified; this page does not infer exception classes or return values.

Security notes

Quoted verbatim from the official documentation; this is not a complete threat model. 来源:https://pkg.go.dev/github.com/gorilla/sessions · 取证方式:HTTP GET 官方 README/文档页(HTML 去标签) · 抓取时间:2026-11-07T13:50:03.878Z.

FAQ

When should I use a server-side store?
When session data is large or must be server-controlled. Cookie sessions are limited by the 4 KB cookie size and are client-visible.
Is the cookie encrypted?
Only when a second key is supplied. Providing just one key signs the cookie, so clients cannot tamper but can read it.
Why is my session not persisting?
Always call Save and ensure the response is not already written. Also confirm the keys are stable across processes.