session

package
v0.0.0-...-896db50 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2022 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GeneralMutex sync.Mutex

Functions

func BuildRandomToken

func BuildRandomToken() string

BuildRandomToken build a random string used for token.

func DestroySession

func DestroySession(token string)

DestroySession destroy a session by token

func LoadSessions

func LoadSessions()

go binary decoder

func SaveSessions

func SaveSessions()

Types

type Session

type Session struct {
	LastAccess time.Time
	Values     map[string]interface{}
	// contains filtered or unexported fields
}

Session struct

func GetSession

func GetSession(token string) *Session

GetSession return the Session instance of the given token. if no session was found for this token, a transient session will be given

func NewSession

func NewSession() (token string, s *Session)

NewSession return a new Session instance, with a new token.

func (*Session) Get

func (session *Session) Get(key string) (value interface{}, ok bool)

Get return a value of any type. ok is false if no value was found

func (*Session) GetDef

func (session *Session) GetDef(key string, def interface{}) interface{}

GetDef return a value of any type. return the "def" parameter if no value was found

func (*Session) GetInt

func (session *Session) GetInt(key string) (value int, ok bool)

GetInt return a value of integer type. ok is false if no value was found

func (*Session) GetIntDef

func (session *Session) GetIntDef(key string, def int) int

GetIntDef return a value of integer type. return the "def" parameter if no value was found

func (*Session) GetString

func (session *Session) GetString(key string) (value string, ok bool)

GetString return a value of string type. ok is false if no value was found

func (*Session) GetStringDef

func (session *Session) GetStringDef(key string, def string) string

GetStringDef return a value of string type. return the "def" parameter if no value was found

func (*Session) Set

func (session *Session) Set(key string, value interface{})

Set any value to a key string.

Jump to

Keyboard shortcuts

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