cookies

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2023 License: Apache-2.0 Imports: 1 Imported by: 0

README

cookies

GoDoc

Package cookies provides the ability to read and edit the contents of browser cookie databases stored in various formats. This is a work in progress.

Documentation

Overview

Package cookies reads and modifies browser cookies.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action int

An Action specifies the disposition of a cookie processed by the callback to the Scan method of a Store.

const (
	Keep    Action = 1 + iota // keep the cookie in the store, unmodified
	Update                    // keep the cookie in the store, with modifications
	Discard                   // discard the cookie from the store
)

Values for the Action enumeration.

func (Action) String

func (a Action) String() string

type C

type C struct {
	Name   string
	Value  string
	Domain string
	Path   string

	Expires  time.Time // if zero, has no expiration
	Created  time.Time
	Flags    Flags
	SameSite SameSite
}

C is a format-independent representation of a browser cookie.

type Editor

type Editor interface {
	// Get returns a format-independent representation of the receiver.
	Get() C

	// Set updates the contents of the receiver to match c.
	// It reports an error if c cannot be represented in the format.
	Set(c C) error
}

An Editor maps between format-specific representation of a cookie and the format-independent version.

type Flags

type Flags struct {
	Secure   bool // only send this cookie on an encrypted connection
	HTTPOnly bool // do not expose this cookie to scripts
}

Flags represents the optional flags that can be set on a cookie.

type SameSite

type SameSite int

SameSite describes a first-party cookie policy.

const (
	Unknown SameSite = iota // unknown or unspecified policy
	Lax                     // top-level navigations and 3rd-party GET requests
	Strict                  // first-party context only
	None                    // unrestricted; send to all origins
)

Enumerators for SameSite policies.

func (SameSite) String

func (s SameSite) String() string

type ScanFunc

type ScanFunc func(Editor) (Action, error)

A ScanFunc is a callback to scan each cookie in a store.

type Store

type Store interface {
	// Scan calls f for each cookie in the store.
	//
	// If f reports an error, scanning stops and that error is returned to the
	// caller of Scan. Otherwise, the cookie is handled according to the Action
	// reported by f.
	//
	// if f returns Discard, the cookie is removed from the store.
	//
	// If f returns Update, the cookie is updated with any modifications made by
	// f via the Editor interface.
	//
	// If f returns Keep, the cookie is retained as-presented, and any
	// modifications made by f are discarded.
	//
	// If f returns an unknown Action value, Scan must report an error.
	Scan(f ScanFunc) error

	// Commit commits any pending modifications to persistent storage.
	Commit() error
}

Store is the interface for a collection of cookies.

Directories

Path Synopsis
Package bincookie supports reading and modifying Apple binary cookie files.
Package bincookie supports reading and modifying Apple binary cookie files.
Package chromedb supports reading and modifying a Chrome cookies database.
Package chromedb supports reading and modifying a Chrome cookies database.
cmd
washcookies
Program washcookies cleans up browser cookies based on a policy.
Program washcookies cleans up browser cookies based on a policy.
washcookies/config
Package config parses the text config file format for the washcookies tool.
Package config parses the text config file format for the washcookies tool.
Package firefox supports reading and modifying a Firefox cookies database.
Package firefox supports reading and modifying a Firefox cookies database.

Jump to

Keyboard shortcuts

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