session

package
v4.0.4 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2021 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func All

func All() int

func Destroy

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

func Exist

func Exist(sid string) bool

func GetSid

func GetSid(r *http.Request) (string, error)

func Init

func Init()

func NewContext

func NewContext(ctx context.Context, s *SessionStore) context.Context
ctx := NewContext(req.Context(), p)
req = req.WithContext(ctx)

NewContext returns a copy of the parent context and associates it with an sessionStore.

func Stop

func Stop()

Types

type Manager

type Manager struct {
	// contains filtered or unexported fields
}
var (
	DefaultSession *Manager
)

func StartSession

func StartSession(cf *config.SessionSection, opts_ ...Option) (*Manager, error)

func (*Manager) All

func (p *Manager) All() int

All count values in mysql session

func (*Manager) Destroy

func (p *Manager) Destroy(w http.ResponseWriter, r *http.Request) (string, error)

func (*Manager) Exist

func (p *Manager) Exist(sid string) bool

func (*Manager) Get

func (p *Manager) Get(sid string) (*SessionStore, error)

func (*Manager) GetSid

func (p *Manager) GetSid(r *http.Request) (sid string, err error)

func (*Manager) Start

func (p *Manager) Start(w http.ResponseWriter, r *http.Request) (store *SessionStore, err error)

SessionStart generate or read the session id from http request. if session id exists, return SessionStore with this id.

func (*Manager) StopGC

func (p *Manager) StopGC()

type Option

type Option interface {
	// contains filtered or unexported methods
}

func WithCtx

func WithCtx(ctx context.Context) Option

func WithMem

func WithMem() Option

type SessionStore

type SessionStore struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

SessionStore mysql session store

func FromContext

func FromContext(ctx context.Context) (s *SessionStore, ok bool)

FromContext returns the Auth bound to the context, if any.

func Get

func Get(sid string) (*SessionStore, error)

func Start

func Start(w http.ResponseWriter, r *http.Request) (store *SessionStore, err error)

func (*SessionStore) CreatedAt

func (p *SessionStore) CreatedAt() int64

func (*SessionStore) Delete

func (p *SessionStore) Delete(k string) error

Delete value in mysql session

func (*SessionStore) Get

func (p *SessionStore) Get(k string) string

Get value from mysql session

func (*SessionStore) Reset

func (p *SessionStore) Reset() error

Reset clear all values in mysql session

func (*SessionStore) Set

func (p *SessionStore) Set(k, v string) error

Set value in mysql session. it is temp value in map.

func (*SessionStore) Sid

func (p *SessionStore) Sid() string

Sid get session id of this mysql session store

func (*SessionStore) Update

func (p *SessionStore) Update(w http.ResponseWriter) error

Jump to

Keyboard shortcuts

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