Back to godoc.org

Package session

v0.0.0-...-d8e89f0
Latest Go to latest

The latest major version is .

Published: Sep 3, 2015 | License: MIT | Module: bitbucket.org/tshannon/freehold

Index

Constants

const (
	// DS is the location of the core datastore
	DS = "core" + string(os.PathSeparator) + "session.ds"

	// CookieName is the name of the cookie where the freehold cookie will be
	CookieName = "freehold_session"
)

type ByCreated

type ByCreated []*Session

ByCreated is for sorting sessions

func (ByCreated) Len

func (s ByCreated) Len() int

func (ByCreated) Less

func (s ByCreated) Less(i, j int) bool

func (ByCreated) Swap

func (s ByCreated) Swap(i, j int)

type Session

type Session struct {
	ID        string `json:"id,omitempty"`
	Expires   string `json:"expires,omitempty"`
	CSRFToken string `json:"CSRFToken,omitempty"`
	IPAddress string `json:"ipAddress,omitempty"`
	Created   string `json:"created,omitempty"`
	UserAgent string `json:"userAgent,omitempty"`
	// contains filtered or unexported fields
}

Session is a freehold session, tracked by a cookie

func All

func All(user *user.User) ([]*Session, error)

All retrieves all sessions for the passed in user

func Get

func Get(r *http.Request) (*Session, error)

Get retrieves a session based on the cookie in the passed in request

func GetByID

func GetByID(id string, user *user.User) (*Session, error)

GetByID retrieves a session by the passed in session id

func New

func New(u *user.User, base *Session) (*Session, error)

New create a new session

func (*Session) Cookie

func (s *Session) Cookie(isSSL bool) *http.Cookie

Cookie creates a cookie based on the given session

func (*Session) Expire

func (s *Session) Expire() error

Expire expires the given session

func (*Session) HandleCSRF

func (s *Session) HandleCSRF(w http.ResponseWriter, r *http.Request) error

HandleCSRF tests if the CSRF token is present and valid

func (*Session) IsExpired

func (s *Session) IsExpired() bool

IsExpired is whether or not the session is expired

func (*Session) Key

func (s *Session) Key() string

Key returns the session's key

func (*Session) User

func (s *Session) User() *user.User

User returns the user for the given session

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier