gosession

package
v0.0.0-...-6049a1a Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2020 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MemcachedProvider

type MemcachedProvider struct {
	Connection *memcache.Client
	KeyPrefix  string
}

MemcachedProvider stores the session in a memcached server

func (*MemcachedProvider) Delete

func (provider *MemcachedProvider) Delete(id string) error

Delete the session with that id

func (*MemcachedProvider) Get

func (provider *MemcachedProvider) Get(id string,
	data *map[string]interface{}) (bool, error)

Get session data

func (*MemcachedProvider) Save

func (provider *MemcachedProvider) Save(
	id string, data map[string]interface{}) error

Save the session in memcache

type Session

type Session struct {
	// public
	Data map[string]interface{}

	ID string
	// contains filtered or unexported fields
}

Session contain the session data

func (*Session) Destroy

func (s *Session) Destroy(w http.ResponseWriter) error

Destroy the session

func (*Session) RenewID

func (s *Session) RenewID(w http.ResponseWriter)

RenewID creates a new session id and saves the session

func (*Session) Save

func (s *Session) Save() error

Save the changes made to the session

type SessionProvider

type SessionProvider interface {
	Save(id string, data map[string]interface{}) error

	Delete(id string) error

	Get(id string, data *map[string]interface{}) (bool, error)
}

SessionProvider is the one that stores the session somewhere

type SessionStore

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

The SessionStore manages the retrieval of a session

func NewCookieBasedSessionStore

func NewCookieBasedSessionStore(
	provider SessionProvider,
	cookie string,
	createWhenMissing bool) *SessionStore

NewCookieBasedSessionStore creates a Cookie based sesion store

func NewHeaderBasedSessionStore

func NewHeaderBasedSessionStore(
	provider SessionProvider,
	header string,
	createWhenMissing bool) *SessionStore

NewHeaderBasedSessionStore create a new SessionStore based with id passed as header values

func (*SessionStore) Get

Get the session for this request

func (*SessionStore) GetByID

func (s *SessionStore) GetByID(id string) (*Session, error)

GetByID returnes the session that corresponds the the ID

func (*SessionStore) New

New ... creates a session

Jump to

Keyboard shortcuts

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