Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DeleteSession ¶
DeleteSession deletes the session with the specific sessionToken and returns an error, if any.
func Setup ¶
func Setup(dbParent *pgx.ConnPool, logParent *ulogger.Logger, sessionExpiresInSecs int64, sessionLocalTimezoneName string)
Setup accepts a db conn pool, a ulogger instance, number of seconds after which the session expires (if set to 0, default value of 86400 is used), the timezone (if set to "", default timezone - UTC is used), and sets up the required variables. It also starts the expiry timers of existing sessions.
func TableSessions ¶
TableSessions creates the Sessions table
Types ¶
type Session ¶
type Session struct {
// ID stores the bigserial (PostgreSQL row id) associated with this session
ID int64 `json:"id,omitempty"`
// Key stores the string that needs to be encoded/hashed to generate a unique session value
Key string `json:"key,omitempty"`
// Token stores the computed token using the key
Token string `json:"token,omitempty"`
// ExpiryIn stores the number of seconds after which this session will expire
ExpiryIn int64 `json:"expiry_in,omitempty"`
// ExpiresAt stores the timestamp (with full timezone) at which this session will expire
ExpiresAt time.Time `json:"expires_at,omitempty"`
// IP stores the IP address of the client requesting a new session
IP string `json:"ip,omitempty"`
// Active stores whether this session is active
Active bool `json:"active,omitempty"`
// Timestamp stores the timestamp in epoch secs when this entry was created
Timestamp int64 `json:"timestamp,omitempty"`
}
Session stores the parameters in the sessions table
func CheckStatus ¶
CheckStatus accepts a session token, and returns the session object, along with an error, if any
func FetchAllSessions ¶
FetchAllSessions returns all the live sessions.
func FetchSessionData ¶
FetchSessionData returns the data of the particular session token