session

package
v0.0.0-...-94183c9 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2020 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	RedisAddress string
	AuthKey      string
	Https        bool
	Secure       bool
}

type Module

type Module struct {
	Service *sessions.Service
}

func New

func New(cfg Config) (*Module, error)

func (*Module) ClearSession

func (m *Module) ClearSession(c *gin.Context)

清空session

func (*Module) DelValue

func (m *Module) DelValue(c *gin.Context, key string)

移除值

func (*Module) GetSessionJSON

func (m *Module) GetSessionJSON(c *gin.Context) (*SessionJSON, error)

func (*Module) GetValue

func (m *Module) GetValue(c *gin.Context, key string) (v interface{}, exist bool)

从session获取值

func (*Module) GetValueString

func (m *Module) GetValueString(c *gin.Context, key string) string

按字符串格式读取一个session值

func (Module) NewSession

func (Module) NewSession() (SessionJSON, error)

func (*Module) SetValue

func (m *Module) SetValue(c *gin.Context, key string, v interface{})

写入session

func (*Module) StartSession

func (m *Module) StartSession(c *gin.Context, noCheckCsrf bool)

对一个request启动session

func (*Module) UpdateSessionInfo

func (m *Module) UpdateSessionInfo(c *gin.Context, sessInfo *user.Session, sessJson *SessionJSON)

func (*Module) UpdateSessionJSON

func (m *Module) UpdateSessionJSON(c *gin.Context, sessJson *SessionJSON)

type SessionJSON

type SessionJSON struct {
	CSRF string                 `json:"csrf"` // 用来防止Cross-site request forgery攻击(多窗口浏览器的cookie安全问题)
	Data map[string]interface{} `json:"data"`
}

SessionJSON is used for marshalling and unmarshalling custom session json information. We're using it as an opportunity to tie csrf strings to sessions to prevent csrf attacks

Jump to

Keyboard shortcuts

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