Documentation ¶
Overview ¶
Package sessions implements an cookie-free session handling system.
Copyright © 2019 M.Watermann, 10247 Berlin, Germany All rights reserved EMail : <support@mwat.de>
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
You should have received a copy of the GNU General Public License along with this program. If not, see the [GNU General Public License](http://www.gnu.org/licenses/gpl.html) for details.
Index ¶
- func SIDname() string
- func SessionTTL() int
- func SetSIDname(aSID string)
- func SetSessionTTL(aTTL int)
- func Wrap(aHandler http.Handler, aSessionDir string) http.Handler
- type TSession
- func (so *TSession) Delete(aKey string) *TSession
- func (so *TSession) Destroy()
- func (so *TSession) Get(aKey string) interface{}
- func (so *TSession) GetBool(aKey string) (bool, bool)
- func (so *TSession) GetFloat(aKey string) (float64, bool)
- func (so *TSession) GetInt(aKey string) (int64, bool)
- func (so *TSession) GetString(aKey string) (string, bool)
- func (so *TSession) GetTime(aKey string) (rTime time.Time, rOK bool)
- func (so *TSession) ID() string
- func (so *TSession) Len() int
- func (so *TSession) Set(aKey string, aValue interface{}) *TSession
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SIDname ¶
func SIDname() string
SIDname returns the configured session name.
This name is expected to be used as a FORM field's name or the name of a CGI argument. Its default value is `SID`.
func SessionTTL ¶
func SessionTTL() int
SessionTTL returns the Time-To-Life of a session (in seconds).
func SetSIDname ¶
func SetSIDname(aSID string)
SetSIDname sets the name of the session ID.
`aSID` identifies the session data.
func SetSessionTTL ¶
func SetSessionTTL(aTTL int)
SetSessionTTL sets the lifetime of a session.
`aTTL` is the number of seconds a session's life lasts.
Types ¶
type TSession ¶
type TSession struct {
// contains filtered or unexported fields
}
TSession is an opaque session data store.
func GetSession ¶
GetSession returns the `TSession` for `aRequest`.
If `aRequest` doesn't provide a session ID in its form values a new (empty) `TSession` instance is returned.
`aRequest` is the HTTP request received by the server.
func (*TSession) Delete ¶
Delete removes the session data identified by `aKey`.
`aKey` The identifier to lookup.
func (*TSession) Destroy ¶
func (so *TSession) Destroy()
Destroy a session.
All internal references and external session files are removed.
func (*TSession) Get ¶
Get returns the session data identified by `aKey`.
If `aKey` doesn't exist the method returns `nil`.
`aKey` The identifier to lookup.
func (*TSession) GetBool ¶ added in v0.1.0
GetBool returns the `boolean` session data identified by `aKey`.
The second (`bool`) return value signals whether a session value of type `bool` is associated with `aKey`.
If `aKey` doesn't exist the method returns `false` and `false`.
`aKey` The identifier to lookup.
func (*TSession) GetFloat ¶ added in v0.1.0
GetFloat returns the `float64` session data identified by `aKey`.
The second (`bool`) return value signals whether a session value of type `float64` is associated with `aKey`.
If `aKey` doesn't exist the method returns `0` (zero) and `false`.
`aKey` The identifier to lookup.
func (*TSession) GetInt ¶ added in v0.1.0
GetInt returns the `int` session data identified by `aKey`.
The second (`bool`) return value signals whether a session value of type `int` is associated with `aKey`.
If `aKey` doesn't exist the method returns `0` (zero) and `false`.
`aKey` The identifier to lookup.
func (*TSession) GetString ¶ added in v0.1.0
GetString returns the `string` session data identified by `aKey`.
The second (`bool`) return value signals whether a session value of type `string` is associated with `aKey`.
If `aKey` doesn't exist the method returns an empty string and `false`.
`aKey` The identifier to lookup.
func (*TSession) GetTime ¶ added in v0.1.0
GetTime returns the `time.Time` session data identified by `aKey`.
The second (`bool`) return value signals whether a session value of type `time.Time` is associated with `aKey`.
If `aKey` doesn't exist the method returns a zero time and `false`.
`aKey` The identifier to lookup.