session

package
v0.0.0-...-5c79d48 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2024 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CookieName is the name of the session cookie.
	CookieName = "__Host-session"
)

Variables

This section is empty.

Functions

func ClearCookie

func ClearCookie(w http.ResponseWriter)

ClearCookie wipes the session cookie to invalidate the user session.

func EncodeCookie

func EncodeCookie(user, sid string) (string, error)

EncodeCookie returns the string representation of a Cookie that should be used to store the user session in the cookies of a http.ResponseWriter.

func SetCookie

func SetCookie(w http.ResponseWriter, user, sid string) error

SetCookie encodes the provided user and session id via EncodeCookie and then sets the http.Cookie of the provided http.ResponseWriter.

Types

type Cookie struct {
	User string `json:"user"`
	SID  string `json:"sid"`
}

Cookie stores information about active user and session

func DecodeCookie

func DecodeCookie(b string) (*Cookie, error)

DecodeCookie returns the Cookie from the provided string.

Jump to

Keyboard shortcuts

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