sessions

package
v0.0.0-...-c2ccda8 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2019 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

sessions provide a way to store user information on their end (in a cookie) the content of the cookie is signed (but not encrypted), hence it can be assumed that it hasn't been altered

cookie session format. Each part is base64 encoded alg.payload.signature it's heavily inspired by JWT, but I was stupid enough to do something *slightly* different

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidSignature = errors.New("session cookie: payload signature didn't match")
View Source
var ErrNoSession = errors.New("no session cookie")

Functions

This section is empty.

Types

type Config

type Config struct {
	CookieName string
	Algorithm  string
	Key        []byte
}

type S

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

S should be instantiated once, and then used for every request

func NewS

func NewS(config *Config) (*S, error)

func (*S) Load

func (s *S) Load(r *http.Request, dst interface{}) error

Load returns the current session. Errors: ErrInvalidSignature, ErrNoSession

func (*S) Remove

func (s *S) Remove(w http.ResponseWriter)

Remove removes the session cookie

func (*S) Save

func (s *S) Save(w http.ResponseWriter, obj interface{}) error

Jump to

Keyboard shortcuts

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