sessions

package
v1.5.3 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Default Session Storage
	// Supported: "database"
	Storage string

	// Database connection
	Connection string

	// Database table
	Table       string
	AutoMigrate bool

	Cookie CookieConfig
}

type CookieConfig

type CookieConfig struct {
	Name           string
	CsrfCookieName string
	Path           string
	Domain         string
	Secure         bool

	/* Here you may specify the number of minutes that you wish the session
	to be allowed to remain idle before it expires. If you want them
	to immediately expire on the browser closing, set that option. */
	Lifetime int
}

type CookieUtil

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

func NewCookieUtil

func NewCookieUtil(cfg CookieConfig) *CookieUtil

func (*CookieUtil) Write

func (c *CookieUtil) Write(ctx *web.Context, data contracts.SessionData)

type Data

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

func NewData

func NewData(id string, csrfToken string, data map[string]interface{}, expiredAt time.Time) *Data

func NewEmptyData

func NewEmptyData(maxAge int64) *Data

func (*Data) CSRFToken

func (d *Data) CSRFToken() string

func (*Data) Clear

func (d *Data) Clear()

Setiap clear harus disertai dengan save

func (*Data) Data

func (d *Data) Data() map[string]interface{}

func (*Data) Delete

func (d *Data) Delete(key string)

Setiap delete harus disertai dengan save

func (*Data) ExpiredAt

func (d *Data) ExpiredAt() time.Time

func (*Data) Get

func (d *Data) Get(key string) (interface{}, bool)

func (*Data) Id

func (d *Data) Id() string

func (*Data) Invalidate

func (d *Data) Invalidate()

func (*Data) RegenerateCSRFToken

func (d *Data) RegenerateCSRFToken()

func (*Data) RegenerateId

func (d *Data) RegenerateId()

func (*Data) Set

func (d *Data) Set(key string, value interface{})

Setiap set harus disertai dengan save

type Service

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

func NewService

func NewService(storage contracts.SessionStorage, writer contracts.SessionCookieWriter, cfg Config) (*Service, error)

func (*Service) Clear

func (s *Service) Clear(ctx *web.Context) error

func (*Service) Delete

func (s *Service) Delete(ctx *web.Context, key string) error

func (*Service) Get

func (s *Service) Get(ctx *web.Context, key string) (interface{}, error)

func (*Service) Invalidate

func (s *Service) Invalidate(ctx *web.Context) error

func (*Service) IsTokenMatch

func (s *Service) IsTokenMatch(ctx *web.Context, token string) (bool, error)

func (*Service) Put

func (s *Service) Put(ctx *web.Context, key string, value interface{}) error

func (*Service) Regenerate

func (s *Service) Regenerate(ctx *web.Context) error

func (*Service) RegenerateToken

func (s *Service) RegenerateToken(ctx *web.Context) error

func (*Service) Start

func (s *Service) Start(ctx *web.Context) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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