Categorygithub.com/flamego/session
modulepackage
1.6.5
Repository: https://github.com/flamego/session.git
Documentation: pkg.go.dev

# README

session

GitHub Workflow Status GoDoc Sourcegraph

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

License

This project is under the MIT License. See the LICENSE file for the full license text.

# Packages

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# 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.

# Interfaces

Flash is anything that gets retrieved and deleted as soon as the next request happens.
Session is a session for the current request.
Store is a session store with capabilities of checking, reading, destroying and GC sessions.

# 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.