@@ -205,6 +205,28 @@ func Options(t *testing.T, newStore storeFactory) {
205205 _ = session .Save ()
206206 c .String (http .StatusOK , ok )
207207 })
208+ r .GET ("/set" , func (c * gin.Context ) {
209+ session := sessions .Default (c )
210+ session .Set ("key" , ok )
211+ _ = session .Save ()
212+ c .String (http .StatusOK , ok )
213+ })
214+ r .GET ("/expire" , func (c * gin.Context ) {
215+ session := sessions .Default (c )
216+ session .Options (sessions.Options {
217+ MaxAge : - 1 ,
218+ })
219+ _ = session .Save ()
220+ c .String (http .StatusOK , ok )
221+ })
222+ r .GET ("/check" , func (c * gin.Context ) {
223+ session := sessions .Default (c )
224+ val := session .Get ("key" )
225+ if val != nil {
226+ t .Fatal ("Session expiration failed" )
227+ }
228+ c .String (http .StatusOK , ok )
229+ })
208230
209231 testOptionSameSitego (t , r )
210232
@@ -216,6 +238,18 @@ func Options(t *testing.T, newStore storeFactory) {
216238 req2 , _ := http .NewRequest ("GET" , "/path" , nil )
217239 r .ServeHTTP (res2 , req2 )
218240
241+ res3 := httptest .NewRecorder ()
242+ req3 , _ := http .NewRequest ("GET" , "/set" , nil )
243+ r .ServeHTTP (res3 , req3 )
244+
245+ res4 := httptest .NewRecorder ()
246+ req4 , _ := http .NewRequest ("GET" , "/expire" , nil )
247+ r .ServeHTTP (res4 , req4 )
248+
249+ res5 := httptest .NewRecorder ()
250+ req5 , _ := http .NewRequest ("GET" , "/check" , nil )
251+ r .ServeHTTP (res5 , req5 )
252+
219253 s := strings .Split (res1 .Header ().Get ("Set-Cookie" ), ";" )
220254 if s [1 ] != " Path=/foo/bar/bat" {
221255 t .Error ("Error writing path with options:" , s [1 ])
0 commit comments