package
1.2.4
Repository: https://github.com/helays/utils.git
Documentation: pkg.go.dev

# README

Session 模块使用指南

使用内存存储

package test

import (
	"github.com/helays/utils/http/session"
	"github.com/helays/utils/http/session/memory"
	"time"
)

var (
	store = &session.Store{}
)

func run() {

	store = session.Init(memory.New(), &session.Options{
		CookieName:    "vsclub.ltd",
		CheckInterval: time.Hour,
		Carrier:       "cookie",
		Path:          "",
		Domain:        "",
		MaxAge:        0,
		Secure:        false,
		HttpOnly:      false,
		SameSite:      0,
	})
}

使用文件存储

package test

import (
	"github.com/helays/utils/http/session"
	"github.com/helays/utils/http/session/file"
	"time"
)

var (
	store = &session.Store{}
)

type User struct{}

func run() {
	engine, _ := file.New(file.Instance{Path: "runtime/session"})
	// 在session中需要存储User 结构体数据,需要将结构体注册进去
	engine.Register(User{})
	store = session.Init(engine, &session.Options{
		CookieName:    "vsclub.ltd",
		CheckInterval: time.Hour,
		Carrier:       "cookie",
		Path:          "",
		Domain:        "",
		MaxAge:        0,
		Secure:        false,
		HttpOnly:      false,
		SameSite:      0,
	})
}

# Packages

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Functions

No description provided by the author
No description provided by the author
GetSessionId 获取sessionId 如果未获取到 sessionId ,则生成一个,并写到响应信息中.
GetSessionName 生成session key 这个key 是存储在 存储系统中的.
Init 初始化session.
SetSessionId 设置sessionId.

# Constants

No description provided by the author
session默认24小时过期.
默认检测频率.

# Variables

No description provided by the author
No description provided by the author

# Structs

Options session 配置.
Session session 数据结构.
No description provided by the author
No description provided by the author

# Interfaces

Dialector session 接口.