cookie

package
v0.9.9 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2025 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNilRequest    = errors.New("nil request")
	ErrNilAttributes = errors.New("nil cookie attributes")
)

Functions

func DeleteCookies added in v0.9.3

func DeleteCookies(w http.ResponseWriter, attributesList ...*Attributes)

DeleteCookies deletes the cookies

func GetTimestampCookie added in v0.9.3

func GetTimestampCookie(
	r *http.Request,
	attributes *Attributes,
) (*time.Time, error)

GetTimestampCookie gets a timestamp cookie

func RenovateCookie added in v0.9.3

func RenovateCookie(
	w http.ResponseWriter,
	r *http.Request,
	attributes *Attributes,
	expiresAt time.Time,
	cookieNotFoundFn func(
		w http.ResponseWriter,
		attributes *Attributes,
		err error,
	) error,
) error

RenovateCookie creates a new cookie with the same value and a new expiration time

func SetCookie

func SetCookie(
	w http.ResponseWriter,
	attributes *Attributes,
	value string,
	expiresAt time.Time,
)

SetCookie sets a cookie

func SetTimestampCookie added in v0.9.3

func SetTimestampCookie(
	w http.ResponseWriter,
	attributes *Attributes,
	value,
	expiresAt time.Time,
)

SetTimestampCookie sets a cookie with a timestamp

Types

type Attributes

type Attributes struct {
	Name     string
	Path     string
	Domain   string
	Secure   bool
	HTTPOnly bool
	SameSite http.SameSite
}

Attributes is the structure for the attributes of a cookie

Jump to

Keyboard shortcuts

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