sessions

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2022 License: ISC Imports: 4 Imported by: 0

README

sessions

-- import "vimagination.zapto.org/sessions"

Package sessions is used to store session information for a web server

Usage

func Domain
func Domain(domain string) optFunc

Domain sets the optional domain for the cookie

func Expiry
func Expiry(d time.Duration) optFunc

Expiry sets a maximum time that a cookie and authenticated message are valid for

func HTTPOnly
func HTTPOnly() optFunc

HTTPOnly sets the httponly flag on the cookie

func Name
func Name(name string) optFunc

Name sets the cookie name

func Path
func Path(path string) optFunc

Path sets the optional path for the cookie

func Secure
func Secure() optFunc

Secure sets the secure flag on the cookie

type CookieStore
type CookieStore struct {
}

CookieStore stores and retrieves authenticated data from a clients cookies

func NewCookieStore
func NewCookieStore(encKey []byte, opts ...optFunc) (*CookieStore, error)

NewCookieStore creates a new CookieStore and initialises it. The options optFunc's are to set non-default values on the cookie.

func (*CookieStore) Get
func (c *CookieStore) Get(r *http.Request) []byte

Get retrieves authenticated data from the cookie

func (*CookieStore) Set
func (c *CookieStore) Set(w http.ResponseWriter, data []byte)

Set stores authenticated data in a clients cookies

type Store
type Store interface {
	Get(*http.Request) []byte
	Set(http.ResponseWriter, []byte)
}

Store is the interface for any stores in this package

Documentation

Overview

Package sessions is used to store session information for a web server

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Domain

func Domain(domain string) optFunc

Domain sets the optional domain for the cookie

func Expiry

func Expiry(d time.Duration) optFunc

Expiry sets a maximum time that a cookie and authenticated message are valid for

func HTTPOnly

func HTTPOnly() optFunc

HTTPOnly sets the httponly flag on the cookie

func Name

func Name(name string) optFunc

Name sets the cookie name

func Path

func Path(path string) optFunc

Path sets the optional path for the cookie

func Secure

func Secure() optFunc

Secure sets the secure flag on the cookie

Types

type CookieStore

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

CookieStore stores and retrieves authenticated data from a clients cookies

func NewCookieStore

func NewCookieStore(encKey []byte, opts ...optFunc) (*CookieStore, error)

NewCookieStore creates a new CookieStore and initialises it. The options optFunc's are to set non-default values on the cookie.

func (*CookieStore) Get

func (c *CookieStore) Get(r *http.Request) []byte

Get retrieves authenticated data from the cookie

func (*CookieStore) Set

func (c *CookieStore) Set(w http.ResponseWriter, data []byte)

Set stores authenticated data in a clients cookies

type Store

type Store interface {
	Get(*http.Request) []byte
	Set(http.ResponseWriter, []byte)
}

Store is the interface for any stores in this package

Jump to

Keyboard shortcuts

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