Categorygithub.com/tommy351/gin-sessions
modulepackage
0.0.0-20150617141853-353060947eb6
Repository: https://github.com/tommy351/gin-sessions.git
Documentation: pkg.go.dev

# README

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")
    })
}

# Functions

Get returns a session in the context.
Middleware helps you set up a session in context.
NewCookieStore creates a new CookieStore.

# Structs

Options stores configurations of a session.

# Interfaces

CookieStore stores sessions using secure cookies.
Session is an interface that stores values and configurations for a session.
Store is an interface for custom session stores.