cookies

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package cookies provides helpers for reading and writing cookies with various security features.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrValueTooLong is returned when the cookie value is too long
	ErrValueTooLong = errors.New("cookie value too long")
	// ErrInvalidValue is returned when the cookie value is invalid
	ErrInvalidValue = errors.New("invalid cookie value")
)

Functions

func Read

func Read(r *http.Request, name string) (string, error)

Read reads a cookie from the request

func ReadEncrypted

func ReadEncrypted(r *http.Request, name string, secretKey string) (string, error)

ReadEncrypted reads an encrypted cookie from the request

func ReadSigned

func ReadSigned(r *http.Request, name string, secretKey string) (string, error)

ReadSigned reads a signed cookie from the request

func Write

func Write(w http.ResponseWriter, cookie http.Cookie) error

Write writes a cookie to the response

func WriteEncrypted

func WriteEncrypted(w http.ResponseWriter, cookie http.Cookie, secretKey string) error

WriteEncrypted writes an encrypted cookie to the response

func WriteSigned

func WriteSigned(w http.ResponseWriter, cookie http.Cookie, secretKey string) error

WriteSigned writes a signed cookie to the response

Types

This section is empty.

Jump to

Keyboard shortcuts

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