Documentation
¶
Index ¶
- type Session
- func (sessionObject *Session) CheckStatus(sessionToken string) (SessionData, error)
- func (sessionObject *Session) DeleteSession(sessionToken string) error
- func (sessionObject *Session) FetchSessionData(session SessionData) (SessionData, error)
- func (sessionObject *Session) NewSession(key string, ipAddress string) (SessionData, error)
- type SessionData
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Session ¶
type Session struct {
Name string
ExpiryTime int64
StorageEngine string
// contains filtered or unexported fields
}
Session manages all the sessions
func Init ¶ added in v1.0.1
func Init(name string, persistSessionToDisk bool, expiryInSecs int64, dbFolderLocation string) (*Session, error)
Init initialises a session object with buntdb as the storage engine a name, a bool representing if the corresponding file needs to be saved to disk, a key expiry time in seconds, and the location of the folder where the database file is stored
func InitRedis ¶ added in v1.0.5
InitRedis initialises a session object with Redis as the storage engine. Pass "" for redisAddr & password, and 0 for db for defaults.
func (*Session) CheckStatus ¶ added in v1.0.1
func (sessionObject *Session) CheckStatus(sessionToken string) (SessionData, error)
CheckStatus accepts a session token, and returns the session object, along with an error, if any
func (*Session) DeleteSession ¶ added in v1.0.1
DeleteSession deletes the session with the specific sessionToken and returns an error, if any.
func (*Session) FetchSessionData ¶ added in v1.0.1
func (sessionObject *Session) FetchSessionData(session SessionData) (SessionData, error)
FetchSessionData returns the data of the particular session token
func (*Session) NewSession ¶ added in v1.0.1
func (sessionObject *Session) NewSession(key string, ipAddress string) (SessionData, error)
NewSession accepts the key to encode, along with the client's IP Address, inserts into the sessions table, sets the delete session timer, and returns a SessionData struct.
type SessionData ¶ added in v1.0.1
type SessionData struct {
// 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"`
// Timestamp stores the timestamp in epoch secs when this entry was created
Timestamp int64 `json:"timestamp,omitempty"`
}
SessionData stores the parameters in the sessions table