# README
session
Package session is a middleware that provides the session management for Flamego.
Installation
The minimum requirement of Go is 1.18.
go get github.com/flamego/session
Getting started
package main
import (
"github.com/flamego/flamego"
"github.com/flamego/session"
)
func main() {
f := flamego.Classic()
f.Use(session.Sessioner())
f.Get("/", func(s session.Session) {
s.Set("user_id", 123)
userID, ok := s.Get("user_id").(int)
// ...
})
f.Run()
}
Getting help
- Read documentation and examples.
- Please file an issue or start a discussion on the flamego/flamego repository.
License
This project is under the MIT License. See the LICENSE file for the full license text.
# Functions
FileIniter returns the Initer for the file session store.
GobDecoder is a session data decoder using Gob.
GobEncoder is a session data encoder using Gob.
MemoryIniter returns the Initer for the memory session store.
NewBaseSession returns a new BaseSession with given session ID.
NewBaseSessionWithData returns a new BaseSession with given session ID and initial data.
Sessioner returns a middleware handler that injects session.Session and session.Store into the request context, which are used for manipulating session data.
# Variables
No description provided by the author
# Structs
BaseSession implements basic operations for the session data.
CookieOptions contains options for setting HTTP cookies.
FileConfig contains options for the file session store.
MemoryConfig contains options for the memory session store.
Options contains options for the session.Sessioner middleware.
# Type aliases
Data is the data structure for storing session data.
Decoder is a decoder to decode binary to session data.
Encoder is an encoder to encode session data to binary.
IDWriter is a function that writes the session ID to client (browser).
Initer takes arbitrary number of arguments needed for initialization and returns an initialized session store.