cookie

package
v1.0.17 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2020 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CookieName cookie key name
	CookieName = "golang-webpc-session"
)

Variables

This section is empty.

Functions

func Decode

func Decode(name, value string, dst interface{}) error

Decode decode cookie

func Encode

func Encode(name string, value interface{}) (string, error)

Encode encode cookie

func Generate

func Generate() (hashKey []byte, blockKey []byte)

Generate generate random key

func IniClient

func IniClient(filename string) (e error)

IniClient client debug init

func Init

func Init(filename string, maxAge time.Duration) (e error)

Init initialize cookie system

func IsInit

func IsInit() bool

IsInit return is init ?

func MaxAge

func MaxAge() int64

MaxAge return max age of timeout

func Save

func Save(filename string, hashKey []byte, blockKey []byte) (e error)

Save save key to file

Types

type Session

type Session struct {
	Name string `json:"name,omitempty"`
	// 是否可獲取shell
	Shell bool `json:"shell,omitempty"`
	// 是否可讀取 檔案
	Read bool `json:"read,omitempty"`
	// 是否可寫入 檔案
	Write bool `json:"write,omitempty"`
	// 是否是 root
	Root bool `json:"root,omitempty"`
}

Session user session info

func FromCookie

func FromCookie(val string) (session *Session, e error)

FromCookie restore session from cookie

func (*Session) Cookie

func (s *Session) Cookie() (string, error)

Cookie encode to cookie

func (*Session) IsRoot

func (s *Session) IsRoot() (yes bool)

IsRoot if user is root return true

func (*Session) String

func (s *Session) String() string

Cookie encode to cookie

Jump to

Keyboard shortcuts

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