websession

package
v0.0.0-...-ecdd364 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package websession provides session management.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Session

type Session struct {
	Name string
	// contains filtered or unexported fields
}

Session stores session level information

func New

func New(name string, manager *scs.SessionManager) *Session

New returns a new session cookie store.

func (*Session) AuthenticatedUser

func (s *Session) AuthenticatedUser(r *http.Request) (string, error)

AuthenticatedUser returns the user ID if authenticated or an error.

func (*Session) CSRF

func (s *Session) CSRF(r *http.Request, token string) bool

CSRF return true if the cross site request forgery token matches what was stored before form submission.

func (*Session) DeleteSessionValue

func (s *Session) DeleteSessionValue(r *http.Request, name string)

DeleteSessionValue deletes a value in the user session.

func (*Session) Login

func (s *Session) Login(r *http.Request, value string)

Login user by storing user ID in request context.

func (*Session) Logout

func (s *Session) Logout(r *http.Request)

Logout and destroy session.

func (*Session) LogoutAll

func (s *Session) LogoutAll(r *http.Request) error

LogoutAll destroys all sessions.

func (*Session) Persist

func (s *Session) Persist(r *http.Request, persist bool)

Persist sets session to persist after browser is closed.

func (*Session) SessionValue

func (s *Session) SessionValue(r *http.Request, name string) string

SessionValue returns a value stored in the user session.

func (*Session) SetCSRF

func (s *Session) SetCSRF(r *http.Request) string

SetCSRF sets a cross site request forgery token for the current request to allow for validation during form submission.

func (*Session) SetSessionValue

func (s *Session) SetSessionValue(r *http.Request, name string, value string) error

SetSessionValue sets a value in the user session or returns an error.

Jump to

Keyboard shortcuts

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