From 9252fd9f5fc2f1761fdf1f0ab3930850b4a487cc Mon Sep 17 00:00:00 2001 From: abraniff Date: Mon, 16 Jan 2017 11:26:11 -0500 Subject: [PATCH 1/2] Update store.go --- store.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/store.go b/store.go index 4ff6b6c..b1cf3c2 100644 --- a/store.go +++ b/store.go @@ -127,6 +127,19 @@ func (s *CookieStore) MaxAge(age int) { } } +// MaxLength sets the maximum length for the store and the underlying cookie +// implementation. +func (s *CookieStore) MaxLength(length int) { + s.Options.MaxLength = length + + // Set the maxAge for each securecookie instance. + for _, codec := range s.Codecs { + if sc, ok := codec.(*securecookie.SecureCookie); ok { + sc.MaxLength(length) + } + } +} + // FilesystemStore ------------------------------------------------------------ var fileMutex sync.RWMutex From 289944e9c5b14088718c69b2d28d489c21e78ede Mon Sep 17 00:00:00 2001 From: abraniff Date: Mon, 16 Jan 2017 11:26:46 -0500 Subject: [PATCH 2/2] Update sessions.go --- sessions.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/sessions.go b/sessions.go index fe0d2bc..cde3c0a 100644 --- a/sessions.go +++ b/sessions.go @@ -22,14 +22,15 @@ const flashesKey = "_flash" // // Fields are a subset of http.Cookie fields. type Options struct { - Path string - Domain string + Path string + Domain string // MaxAge=0 means no 'Max-Age' attribute specified. // MaxAge<0 means delete cookie now, equivalently 'Max-Age: 0'. // MaxAge>0 means Max-Age attribute present and given in seconds. - MaxAge int - Secure bool - HttpOnly bool + MaxAge int + MaxLength int + Secure bool + HttpOnly bool } // Session --------------------------------------------------------------------