session

GitHub Workflow Status Codecov GoDoc Sourcegraph

Package session is a middleware that provides the session management for Flamego.

Installation

The minimum requirement of Go is 1.16.

  1. go get github.com/flamego/session

Getting started

  1. package main
  2. import (
  3. "github.com/flamego/flamego"
  4. "github.com/flamego/session"
  5. )
  6. func main() {
  7. f := flamego.Classic()
  8. f.Use(session.Sessioner())
  9. f.Get("/", func(s session.Session) {
  10. s.Set("user_id", 123)
  11. userID, ok := s.Get("user_id").(int)
  12. // ...
  13. })
  14. f.Run()
  15. }

Getting help

License

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