Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add MaxLength #8

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions sqlitestore.go
Original file line number Diff line number Diff line change
@@ -223,7 +223,7 @@ func (m *SqliteStore) Delete(r *http.Request, w http.ResponseWriter, session *se
}

func (m *SqliteStore) save(session *sessions.Session) error {
if session.IsNew == true {
if session.IsNew {
return m.insert(session)
}
var createdOn time.Time
@@ -267,9 +267,9 @@ func (m *SqliteStore) load(session *sessions.Session) error {
if scanErr != nil {
return scanErr
}
if sess.expiresOn.Sub(time.Now()) < 0 {
if time.Until(sess.expiresOn) < 0 {
log.Printf("Session expired on %s, but it is %s now.", sess.expiresOn, time.Now())
return errors.New("Session expired")
return errors.New("session expired")
}
err := securecookie.DecodeMulti(session.Name(), sess.data, &session.Values, m.Codecs...)
if err != nil {
@@ -281,3 +281,11 @@ func (m *SqliteStore) load(session *sessions.Session) error {
return nil

}

func (m *SqliteStore) MaxLength(l int) {
for _, c := range m.Codecs {
if codec, ok := c.(*securecookie.SecureCookie); ok {
codec.MaxLength(l)
}
}
}