Skip to content

Commit 18b3e66

Browse files
authored
Merge pull request #10 from pavansokkenagaraj/pa1/add-max-length
add MaxLength
2 parents c4d60fb + bc2c31a commit 18b3e66

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

mongostore.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,17 @@ func (m *MongoStore) MaxAge(age int) {
159159
}
160160
}
161161

162+
// MaxLength restricts the maximum length of new sessions to l.
163+
// If l is 0 there is no limit to the size of a session, use with caution.
164+
// The default for a new Store is 4096.
165+
func (m *MongoStore) MaxLength(l int) {
166+
for _, c := range m.Codecs {
167+
if codec, ok := c.(*securecookie.SecureCookie); ok {
168+
codec.MaxLength(l)
169+
}
170+
}
171+
}
172+
162173
func (m *MongoStore) load(session *sessions.Session) error {
163174
s := Session{}
164175
err := m.coll.FindOne(context.TODO(), makeFilterByID(session.ID)).Decode(&s)

0 commit comments

Comments
 (0)