37 lines
755 B
Go
37 lines
755 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 struct {
|
||
|
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) assession.Session {
|
||
|
return SessionDestroy(w, r)
|
||
|
}
|