mirror of
https://github.com/speatzle/nfsense.git
synced 2025-05-11 19:08:20 +00:00
Increase Session LifeTime
This commit is contained in:
parent
92246048e6
commit
bdbbae825a
1 changed files with 3 additions and 2 deletions
|
@ -13,6 +13,7 @@ type SessionKeyType string
|
||||||
|
|
||||||
const SessionKey SessionKeyType = "session"
|
const SessionKey SessionKeyType = "session"
|
||||||
const SessionCookieName string = "session"
|
const SessionCookieName string = "session"
|
||||||
|
const SessionLifeTime = time.Minute * 15
|
||||||
|
|
||||||
type Session struct {
|
type Session struct {
|
||||||
Username string
|
Username string
|
||||||
|
@ -42,7 +43,7 @@ func ExtendSession(s *Session) {
|
||||||
sessionsSync.Lock()
|
sessionsSync.Lock()
|
||||||
defer sessionsSync.Unlock()
|
defer sessionsSync.Unlock()
|
||||||
if s != nil {
|
if s != nil {
|
||||||
s.Expires = time.Now().Add(time.Minute * 5)
|
s.Expires = time.Now().Add(SessionLifeTime)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,7 +61,7 @@ func GetSession(r *http.Request) (string, *Session) {
|
||||||
|
|
||||||
func GenerateSession(w http.ResponseWriter, username string) {
|
func GenerateSession(w http.ResponseWriter, username string) {
|
||||||
id := uuid.New().String()
|
id := uuid.New().String()
|
||||||
expires := time.Now().Add(time.Minute * 5)
|
expires := time.Now().Add(SessionLifeTime)
|
||||||
sessionsSync.Lock()
|
sessionsSync.Lock()
|
||||||
defer sessionsSync.Unlock()
|
defer sessionsSync.Unlock()
|
||||||
sessions[id] = &Session{
|
sessions[id] = &Session{
|
||||||
|
|
Loading…
Add table
Reference in a new issue