Merge pull request #8 from elithrar/max-age-fix
Provide method to set MaxAge on underlying cookies.
This commit is contained in:
commit
4cff112644
16
pgstore.go
16
pgstore.go
|
@ -90,6 +90,8 @@ func (db *PGStore) New(r *http.Request, name string) (*sessions.Session, error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
db.MaxAge(db.Options.MaxAge)
|
||||||
|
|
||||||
return session, err
|
return session, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,6 +138,20 @@ func (s *PGStore) MaxLength(l int) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MaxAge sets the maximum age for the store and the underlying cookie
|
||||||
|
// implementation. Individual sessions can be deleted by setting Options.MaxAge
|
||||||
|
// = -1 for that session.
|
||||||
|
func (db *PGStore) MaxAge(age int) {
|
||||||
|
db.Options.MaxAge = age
|
||||||
|
|
||||||
|
// Set the maxAge for each securecookie instance.
|
||||||
|
for _, codec := range db.Codecs {
|
||||||
|
if sc, ok := codec.(*securecookie.SecureCookie); ok {
|
||||||
|
sc.MaxAge(age)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//load fetches a session by ID from the database and decodes its content into session.Values
|
//load fetches a session by ID from the database and decodes its content into session.Values
|
||||||
func (db *PGStore) load(session *sessions.Session) error {
|
func (db *PGStore) load(session *sessions.Session) error {
|
||||||
var s Session
|
var s Session
|
||||||
|
|
Loading…
Reference in New Issue