23 lines
389 B
Go
23 lines
389 B
Go
|
package user
|
||
|
|
||
|
import (
|
||
|
"github.com/gin-contrib/sessions"
|
||
|
"github.com/gin-gonic/gin"
|
||
|
)
|
||
|
|
||
|
// SetSession 设置session
|
||
|
func SetSession(c *gin.Context, list map[string]interface{}) {
|
||
|
s := sessions.Default(c)
|
||
|
for key, value := range list {
|
||
|
s.Set(key, value)
|
||
|
}
|
||
|
s.Save()
|
||
|
}
|
||
|
|
||
|
// ClearSession 清空session
|
||
|
func ClearSession(c *gin.Context) {
|
||
|
s := sessions.Default(c)
|
||
|
s.Clear()
|
||
|
s.Save()
|
||
|
}
|