All Projects → tommy351 → Gin Sessions

tommy351 / Gin Sessions

Licence: mit
Session middleware for Gin.

Programming Languages

go
31211 projects - #10 most used programming language

gin-sessions

Build Status

Session middleware for Gin.

Installation

$ go get github.com/tommy351/gin-sessions

Usage

import (
    "github.com/gin-gonic/gin"
    "github.com/tommy351/gin-sessions"
)

func main(){
    g := gin.New()
    store := sessions.NewCookieStore([]byte("secret123"))
    g.Use(sessions.Middleware("my_session", store))
    
    g.GET("/set", func(c *gin.Context){
        session := sessions.Get(c)
        session.Set("hello", "world")
        session.Save()
    })
    
    g.GET("/get", func(c *gin.Context){
        session := sessions.Get(c)
        session.Get("hello")
    })
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].