cookies

package
v0.0.0-...-aca82e5 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

README

Package cloudeng.io/webapp/cookies

import cloudeng.io/webapp/cookies

Types

Type ScopeAndDuration
type ScopeAndDuration struct {
	Domain   string
	Path     string
	Duration time.Duration
}

ScopeAndDuration represents the scope and duration settings for cookies.

Methods
func (d ScopeAndDuration) Cookie(value string) *http.Cookie

Cookie returns a new http.Cookie with the specified value and the scope and duration settings from the ScopeAndDuration receiver.

func (d ScopeAndDuration) SetDefaults(domain, path string, duration time.Duration) ScopeAndDuration

SetDefaults uses the supplied values as defaults for ScopeAndDuration if the current values are not already set.

Type Secure
type Secure string

Secure represents a named cookie that is set 'securely'. It is primarily intended to document and track the use of cookies in a web application.

Methods
func (c Secure) Read(r *http.Request) (string, bool)

Read reads the cookie from the request and returns its value. If the cookie is not present, it returns an empty string and false.

func (c Secure) ReadAndClear(rw http.ResponseWriter, r *http.Request) (string, bool)

ReadAndClear reads a cookie and requests its removal by setting its MaxAge to -1 and its value to an empty string.

func (c Secure) Set(rw http.ResponseWriter, ck *http.Cookie)

Set sets the supplied cookie securely with the name of the cookie specified in the receiver and secure values for HttpOnly, Secure and SameSite (true, true, SameSiteStrictMode). All other fields in ck are used as specified.

Type T
type T string

T represents a named cookie. It is primarily intended to document and track the use of cookies in a web application.

Methods
func (c T) Read(r *http.Request) (string, bool)

Read reads the cookie from the request and returns its value. If the cookie is not present, it returns an empty string and false.

func (c T) ReadAndClear(rw http.ResponseWriter, r *http.Request) (string, bool)

ReadAndClear reads a cookie and requests its removal by setting its MaxAge to -1 and its value to an empty string.

func (c T) Set(rw http.ResponseWriter, ck *http.Cookie)

Set sets the supplied cookie with the name of the cookie specified in the receiver. It overwrites the Name in ck. All other fields in ck are used as specified.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ScopeAndDuration

type ScopeAndDuration struct {
	Domain   string
	Path     string
	Duration time.Duration
}

ScopeAndDuration represents the scope and duration settings for cookies.

func (ScopeAndDuration) Cookie

func (d ScopeAndDuration) Cookie(value string) *http.Cookie

Cookie returns a new http.Cookie with the specified value and the scope and duration settings from the ScopeAndDuration receiver.

func (ScopeAndDuration) SetDefaults

func (d ScopeAndDuration) SetDefaults(domain, path string, duration time.Duration) ScopeAndDuration

SetDefaults uses the supplied values as defaults for ScopeAndDuration if the current values are not already set.

type Secure

type Secure string

Secure represents a named cookie that is set 'securely'. It is primarily intended to document and track the use of cookies in a web application.

func (Secure) Read

func (c Secure) Read(r *http.Request) (string, bool)

Read reads the cookie from the request and returns its value. If the cookie is not present, it returns an empty string and false.

func (Secure) ReadAndClear

func (c Secure) ReadAndClear(rw http.ResponseWriter, r *http.Request) (string, bool)

ReadAndClear reads a cookie and requests its removal by setting its MaxAge to -1 and its value to an empty string.

func (Secure) Set

func (c Secure) Set(rw http.ResponseWriter, ck *http.Cookie)

Set sets the supplied cookie securely with the name of the cookie specified in the receiver and secure values for HttpOnly, Secure and SameSite (true, true, SameSiteStrictMode). All other fields in ck are used as specified.

type T

type T string

T represents a named cookie. It is primarily intended to document and track the use of cookies in a web application.

func (T) Read

func (c T) Read(r *http.Request) (string, bool)

Read reads the cookie from the request and returns its value. If the cookie is not present, it returns an empty string and false.

func (T) ReadAndClear

func (c T) ReadAndClear(rw http.ResponseWriter, r *http.Request) (string, bool)

ReadAndClear reads a cookie and requests its removal by setting its MaxAge to -1 and its value to an empty string.

func (T) Set

func (c T) Set(rw http.ResponseWriter, ck *http.Cookie)

Set sets the supplied cookie with the name of the cookie specified in the receiver. It overwrites the Name in ck. All other fields in ck are used as specified.

Jump to

Keyboard shortcuts

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