cookie

package
v3.30.0 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cookie struct {
	// Name is the name of the cookie.
	Name string

	// Path is path of the cookie.
	Path string

	// MaxAge is the max age of the cookie.
	MaxAge time.Duration

	// HTTPOnly restricts the cookie to HTTP (no javascript access).
	HTTPOnly bool

	// SameSite restricts usage of the cookie in cross-site requests.
	SameSite http.SameSite
}

Cookie is a description of a cookie used for consistent cookie setting and deleting.

func (*Cookie) Exists

func (d *Cookie) Exists(r *http.Request) bool

Exists checks if the cookies exists.

func (*Cookie) Get

func (d *Cookie) Get(w http.ResponseWriter, r *http.Request, v any) (bool, error)

Get decodes the cookie into the value. Returns false if the cookie is not there.

func (*Cookie) Remove

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

Remove the cookie with the specified name (if it exists).

func (*Cookie) Set

func (d *Cookie) Set(w http.ResponseWriter, r *http.Request, v any) error

Set the value of the cookie.

Jump to

Keyboard shortcuts

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