sessionx

package
v2.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 10, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SessionMiddlewareGinx

type SessionMiddlewareGinx interface {
	Sessionx(name string) gin.HandlerFunc
}

func NewSessionMiddlewareGinx

func NewSessionMiddlewareGinx(store sessions.Store) SessionMiddlewareGinx

NewMiddlewareGinx 【注册到gin中间件, server.use()】【store】需要【NewStore】一个【cookie实现就cookie.NewStore,redis实现就Redis.NewStore。。。】

【业务逻辑一般设置】
sess := sessions.Default(ctx)
sess.Set("userId", u.Id) // 设置用户id,把用户Id放入session中
sess.Options(sessions.Options{
	MaxAge: 600, // 设置session过期时间,单位为秒
})
err := sess.Save() // 保存session,save才会以上sess设置才生效

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL