session

package module
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2021 License: MIT Imports: 9 Imported by: 0

README

cotton-session

session middleware for cotton

usage

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SessionCookieName = "sessionid"

SessionCookieName session cookie name

Functions

func HasUsedSession

func HasUsedSession(ctx *cotton.Context) bool

HasUsedSession check whether used session

func Middleware

func Middleware(mgr IMgr) cotton.HandlerFunc

Middleware middleware

Types

type IMgr

type IMgr interface {
	Create(key string) ISession
	Get(id string) (ISession, bool)
	SetMaxExpired(int)
	GetMaxExpired() int
}

IMgr mgr interface

func NewMemcacheMgr

func NewMemcacheMgr(addr string) IMgr

NewMemcacheMgr get memcache session mgr

func NewMemoryMgr

func NewMemoryMgr() IMgr

NewMemoryMgr get memory session mgr

func NewRedisMgr

func NewRedisMgr(addr string, db int, passwd string) IMgr

NewRedisMgr get redis session mgr

type ISession

type ISession interface {
	GetID() string
	Get(key string) (value interface{}, err error)
	Set(key string, value interface{})
	Del(key string)
	Save() error
	Expired(expired int)
	IsExpired(toExpired int64) bool
}

ISession session interface

func GetSession

func GetSession(ctx *cotton.Context) (session ISession)

GetSession get session

Jump to

Keyboard shortcuts

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