cookies

package
v1.9.66 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Commands for interacting with the browser's cookie storage backend.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Commands

type Commands struct {
	friendscript.Module
	// contains filtered or unexported fields
}

func New

func New(browser *browser.Browser, scopeable utils.Scopeable) *Commands

func (*Commands) Clear

func (self *Commands) Clear() error

Clears all browser cookies.

func (*Commands) Delete

func (self *Commands) Delete(name string, args *DeleteArgs) error

Deletes a cookie by name, and optionally matching additional criteria.

func (*Commands) Get

func (self *Commands) Get(name string) (*Cookie, error)

Get a cookie by its name.

func (*Commands) List

func (self *Commands) List(args *ListArgs) ([]*Cookie, error)

List all cookies, either for the given set of URLs or for the current tab (if omitted).

func (*Commands) Map

func (self *Commands) Map(args *ListArgs) (map[string]string, error)

A variant of cookies::list that returns matching cookies as a map of name=value pairs.

func (*Commands) Set

func (self *Commands) Set(cookie *Cookie) error

Set a cookie.

type Cookie struct {
	// The name of the cookie.
	Name string `json:"name"`

	// The cookie's value.
	Value string `json:"value"`

	// The applicable domain for the cookie.
	Domain string `json:"domain"`

	// The cookie's path.
	Path string `json:"path"`

	// The size of the cookie.
	Size int `json:"size"`

	// The cookie's expiration date.
	Expires *time.Time `json:"expires"`

	// The cookie is flagged as being inaccessible to client-side scripts.
	HttpOnly bool `json:"http_only"`

	// The cookie is flagged as "secure"
	Secure bool `json:"secure"`

	// This is a session cookie.
	Session bool `json:"session"`

	// The same site value of the cookie ("Strict" or "Lax")
	SameSite string `json:"same_site"`

	// The URL the cookie should refer to (when setting)
	URL string `json:"url,omitempty"`
}

type DeleteArgs

type DeleteArgs struct {
	// Deletes all cookies with the given name where domain and path match the given URL.
	URL string `json:"url"`

	// If specified, deletes only cookies with this exact domain.
	Domain string `json:"domain"`

	// If specified, deletes only cookies with this exact path.
	Path string `json:"path"`
}

type ListArgs

type ListArgs struct {
	// an array of strings representing the URLs to retrieve cookies for.  If omitted, the
	// URL of the current browser tab will be used
	Urls []string `json:"urls"`

	// A list of cookie names to include in the output.  If non-empty, only these cookies will appear (if present).
	Names []string `json:"names"`
}

Jump to

Keyboard shortcuts

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