session

package
v1.0.24 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MaxAge int
View Source
var SidKey = "sid"

Functions

func GetDomain

func GetDomain(host string) string

获取域名

func GetIP

func GetIP(r *http.Request) string

获取ip

func Init

func Init()

func NewUserSession

func NewUserSession(resource *crud.Resource, uid string, r *http.Request, w http.ResponseWriter) string

func RemoveUserSession added in v1.0.9

func RemoveUserSession(resource *crud.Resource, r *http.Request)

func SaveSessionId

func SaveSessionId(r *http.Request, w http.ResponseWriter) *http.Cookie

func SetUserSession added in v1.0.9

func SetUserSession(r *http.Request, session *UserSession)

func WrapUserSession added in v1.0.9

func WrapUserSession(resource *crud.Resource, r *http.Request)

Types

type UserSession

type UserSession struct {
	base.BaseId `bson,inline`
	Uid         *primitive.ObjectID `bson:"uid" json:"uid"`
	Expires     *time.Time          `bson:"expires,omitempty" json:"expires,omitempty"`
	Agent       string              `bson:"agent,omitempty" json:"agent,omitempty"`
	Ip          string              `bson:"ip,omitempty" json:"ip,omitempty"`
	Status      string              `bson:"status" json:"status"`
}

用户session模型

func GetUserSession added in v1.0.9

func GetUserSession(r *http.Request) *UserSession

获取 session

func (*UserSession) GetUid added in v1.0.9

func (u *UserSession) GetUid() string

Jump to

Keyboard shortcuts

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