filesession

package
v0.0.0-...-2c34b4b Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2022 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

由于跨程序共享session使用的是Gob,在session中有用户自定义类型时,如果另一程序未预先注册此UserType,会报错 因此,暂不考虑跨程序共享session时的资源互斥问题,顾将//(1)处代码注释掉

为避免任何隐藏麻烦,在Encode时如失败不会去尝试gob.Register注册,会直接报错。 以免上一次Encode失败时尝试注册的的类型再Decode时不被识别到,而报错。 顾在程序运行时,尽可能完整的做好测试,再遇到Encode出错时,预注册好此用户自定义类型 注册方式可以: import "encoding/gob"

func init() {
	gob.Register([UserType的初始化])
}

如果明确知晓session的传输类型,并且在linux系统环境下,可以将//(1)代码解除注释,将//(2)代码注释即可

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SessionManager

type SessionManager struct {
	CookieName   string
	CookieDomain string
	// contains filtered or unexported fields
}

func New

func New(cookieName, cookieDomain string, expires int, sessionDir string, timerDuration string) *SessionManager

func (*SessionManager) Clear

func (s *SessionManager) Clear(sessionSign string)

func (*SessionManager) GC

func (s *SessionManager) GC()

func (*SessionManager) Get

func (s *SessionManager) Get(rw http.ResponseWriter, req *http.Request) map[string]interface{}

func (*SessionManager) Len

func (s *SessionManager) Len() int64

func (*SessionManager) Set

func (s *SessionManager) Set(session map[string]interface{}, rw http.ResponseWriter, req *http.Request)

Jump to

Keyboard shortcuts

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