sessions

package
v0.0.0-...-4c3d7af Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrUserNotLoggedIn give error when session does not account you of logging in
	ErrUserNotLoggedIn = errors.New("you must login first")
)

Functions

This section is empty.

Types

type Session

type Session struct {
	// contains filtered or unexported fields
}

Session is used for storing session cookies

func New

func New(secret, sessionName string) *Session

New creates new session using a secret key

func (*Session) Get

func (s *Session) Get(r *http.Request, key string) (interface{}, error)

Get is used to get a value of any type that is temporarily saved by a key, returns interface to be marshalled

func (*Session) GetInt64

func (s *Session) GetInt64(r *http.Request, key string) (int64, error)

GetInt64 is used to get value that is temporarily saved by a key, returns an int64 preferably the user id

func (*Session) Set

func (s *Session) Set(w http.ResponseWriter, r *http.Request, key string, value interface{}) error

func (*Session) UnSet

func (s *Session) UnSet(w http.ResponseWriter, r *http.Request, key string) error

Jump to

Keyboard shortcuts

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