cookie

package
v1.8.2-rc2 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: MIT Imports: 3 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	SameSiteLax    = "Lax"
	SameSiteStrict = "Strict"
	SameSiteNone   = "None"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AppsecCookie

type AppsecCookie struct {
	Name         string
	Expiration   int64
	Val          string
	PathVal      string
	DomainName   string
	SecureFlag   bool
	HttpOnlyFlag bool
	SameSiteMode string
	// PartitionedFlag keys the cookie to the top-level site (CHIPS), so it
	// survives third-party cookie blocking in cross-site iframes.
	PartitionedFlag bool
}

AppsecCookie is the value-type passed around through expr rules to build up a Set-Cookie header. Rule authors construct it via cookie.AppsecCookie(name) and chain the builder methods below; the final String() call renders it to a Set-Cookie-compatible string.

func Cookie(name string) *AppsecCookie

Cookie is a short alias for NewAppsecCookie.

func NewAppsecCookie

func NewAppsecCookie(name string) *AppsecCookie

NewAppsecCookie returns a cookie pre-populated with sensible defaults. Defaults: Path "/", SameSite=Lax, session lifetime, not secure/httponly unless set.

func (*AppsecCookie) Domain

func (c *AppsecCookie) Domain(domain string) *AppsecCookie

Domain sets the cookie Domain attribute. Leave unset to scope the cookie to the request host.

func (*AppsecCookie) ExpiresAt

func (c *AppsecCookie) ExpiresAt(t time.Time) *AppsecCookie

ExpiresAt sets an absolute expiration time (unix seconds).

func (*AppsecCookie) ExpiresIn

func (c *AppsecCookie) ExpiresIn(d time.Duration) *AppsecCookie

ExpiresIn sets the expiration relative to now.

func (*AppsecCookie) HttpOnly

func (c *AppsecCookie) HttpOnly() *AppsecCookie

HttpOnly marks the cookie HttpOnly so it cannot be read from JS.

func (*AppsecCookie) Partitioned added in v1.8.2

func (c *AppsecCookie) Partitioned() *AppsecCookie

Partitioned marks the cookie Partitioned. Implies Secure.

func (*AppsecCookie) Path

func (c *AppsecCookie) Path(path string) *AppsecCookie

Path sets the cookie Path attribute; empty input restores the default ("/").

func (*AppsecCookie) SameSite

func (c *AppsecCookie) SameSite(mode string) *AppsecCookie

SameSite sets the SameSite mode (Lax / Strict / None). Unknown values are passed through verbatim; validation happens on String() rendering.

func (*AppsecCookie) Secure

func (c *AppsecCookie) Secure() *AppsecCookie

Secure marks the cookie Secure. Required when SameSite=None.

func (*AppsecCookie) String

func (c *AppsecCookie) String() string

String formats the cookie into a Set-Cookie compatible string.

func (*AppsecCookie) Value

func (c *AppsecCookie) Value(value string) *AppsecCookie

Value sets the cookie's value.

Jump to

Keyboard shortcuts

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