sessions

package
v0.0.0-...-2ec961a Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoConnection = errors.New("connection to redispack has not been established")

Errors

View Source
var Redis_Pool *redis.Pool

Functions

func Connect

func Connect(options SessionOptions) error

Connect to the Redis server we'll be using for session storage.

func End

func End() error

End closes the connection with redispack

func HasSession

func HasSession(r *http.Request) (bool, error)

HasSession lets you check an incoming request for an existing session.

func Start_session

func Start_session(w http.ResponseWriter, r *http.Request) error

Types

type Session

type Session struct {
	sync.Mutex
	ID     string                 `json:"sessionId"`
	Values map[string]interface{} `json:"values"`
}
var Gsession *Session

func Open

func Open(w http.ResponseWriter, r *http.Request) (*Session, error)

Open will either get a session from an existing ID or if the cookie cannot be found a new session will be returned

func (*Session) Clear

func (s *Session) Clear()

Clear an existing session

func (*Session) Get

func (s *Session) Get(param string) interface{}

Get will return the value from an existing session

func (*Session) Set

func (s *Session) Set(param string, val interface{}) error

Set a value on a session and store it to redispack

type SessionOptions

type SessionOptions struct {
	SessionKey string
	Timeout    string
}

Jump to

Keyboard shortcuts

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