session

package
v1.1.4 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2022 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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

Functions

func GetCurrentDirectory added in v1.1.3

func GetCurrentDirectory() string

获取运行路径

func GetDomain

func GetDomain(host string) string

获取域名

func GetIP

func GetIP(r *http.Request) string

获取ip

func GetUserId added in v1.0.37

func GetUserId(r *http.Request) string

获取 session 的登录id

func Init

func Init(resource *crud.Resource, r *gin.Engine)

func RemoveUserSession added in v1.0.9

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

退出登录

Types

type UserSession

type UserSession struct {
	base.BaseId `bson,inline`
	Uid         string     `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"`
	// login、logout
	Status string `bson:"status" json:"status"`
	// 头像
	Avatar   string `bson:"avatar" json:"avatar"`
	NickName string `bson:"nickName" json:"nickName"`

	MaxAge int64 `bson:"-"`
}

用户session模型

func GetUserSession added in v1.0.9

func GetUserSession(r *http.Request) *UserSession

获取dession

func NewUserSession

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

Jump to

Keyboard shortcuts

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