37 lines
738 B
Go
37 lines
738 B
Go
package session
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
assession "github.com/astaxie/session"
|
|
_ "github.com/astaxie/session/providers/memory"
|
|
)
|
|
|
|
// Session a Session object with all data
|
|
type Session interface {
|
|
assession.Session
|
|
}
|
|
|
|
// Data of readed configuration
|
|
var data *assession.Manager
|
|
|
|
// Init session manager
|
|
func Init() {
|
|
data, _ = assession.NewManager("memory", "session", 3600)
|
|
}
|
|
|
|
// Stop cleanup session manager
|
|
func Stop() {
|
|
data.GC()
|
|
}
|
|
|
|
// SessionStart init a session on a request
|
|
func SessionStart(w http.ResponseWriter, r *http.Request) assession.Session {
|
|
return data.SessionStart(w, r)
|
|
}
|
|
|
|
// SessionDestroy destroy a session on a request
|
|
func SessionDestroy(w http.ResponseWriter, r *http.Request) {
|
|
data.SessionDestroy(w, r)
|
|
}
|