cookie

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package cookie implements an HTTP cookie jar with thread-safe storage and automatic cookie management for HTTP clients.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Jar

type Jar struct {
	// contains filtered or unexported fields
}

Jar is a thread-safe cookie jar that stores cookies per host. It implements http.CookieJar interface for compatibility.

func New

func New() *Jar

New creates a new empty cookie jar.

func (*Jar) CleanExpired

func (j *Jar) CleanExpired()

CleanExpired removes all expired cookies from the jar.

func (*Jar) Clear

func (j *Jar) Clear()

Clear removes all cookies from the jar.

func (*Jar) ClearHost

func (j *Jar) ClearHost(host string)

ClearHost removes all cookies for a specific host.

func (*Jar) Cookies

func (j *Jar) Cookies(u *url.URL) []*http.Cookie

Cookies returns cookies for the given URL. Implements http.CookieJar interface.

func (*Jar) Count

func (j *Jar) Count() int

Count returns the total number of cookies stored.

func (*Jar) DeleteCookie

func (j *Jar) DeleteCookie(u *url.URL, name string)

DeleteCookie removes a cookie by name for the given URL.

func (*Jar) GetCookie

func (j *Jar) GetCookie(u *url.URL, name string) *http.Cookie

GetCookie returns a specific cookie by name for the given URL, or nil if not found.

func (*Jar) SetCookie

func (j *Jar) SetCookie(u *url.URL, cookie *http.Cookie)

SetCookie sets a single cookie for the given URL.

func (*Jar) SetCookies

func (j *Jar) SetCookies(u *url.URL, cookies []*http.Cookie)

SetCookies stores cookies for the given URL. Implements http.CookieJar interface.

Jump to

Keyboard shortcuts

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