session

package
v0.0.0-...-6b4cc3a Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2019 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//DefaultTTL is the default time to live for a session in seconds
	DefaultTTL = 360
)

Variables

This section is empty.

Functions

func Load

func Load(cookieName string, ses *Session, req *http.Request) error

Load loades a session from the data found in the http request under the given cookie name

func Save

func Save(cookieName string, ses *Session, res http.ResponseWriter) error

Save saves a session cookie in to the response to an http request under the given cookie name.

Types

type Serializable

type Serializable interface {
	//called to produce a string which will be stored in session cookie
	MarshalBinary() (data []byte, err error)
	//called to initialize object from a string stored in the session cookie
	UnmarshalBinary(data []byte) error
	//identifier used to identify this objects string in the session cookie
	GetIdentifier() string
}

Serializable is an object that can be serialized in to the session cookie.

type Session

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

Session represents a session retrieved from an http request.

func NewSession

func NewSession(key string) (*Session, error)

NewSession constructs a new session with the given encryption key.

func (*Session) Add

func (session *Session) Add(obj Serializable)

Add adds a serializable object to the session

func (*Session) FromBuffer

func (session *Session) FromBuffer(buffer []byte) error

FromBuffer builds the session object from a session object buffer

func (*Session) GetBuffer

func (session *Session) GetBuffer() ([]byte, error)

GetBuffer "compile" session in to byte buffer

func (*Session) GetIV

func (session *Session) GetIV() string

GetIV gets the iv for the session

func (*Session) GetKey

func (session *Session) GetKey() string

GetKey gets the key for the session

func (*Session) GetSessionObjects

func (session *Session) GetSessionObjects() []Serializable

GetSessionObjects returns a list of all objects associated with the session

func (*Session) SetIV

func (session *Session) SetIV(iv string)

SetIV sets the iv for the session

func (*Session) SetKey

func (session *Session) SetKey(key string)

SetKey sets the key for the session

Jump to

Keyboard shortcuts

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