bsed / gorilla

Automatically exported from code.google.com/p/gorilla
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

[sessions] Add session.Delete() #42

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Add a convenience function that sets the session cookie to be deleted, since 
this is so common.

It could be called session.Delete() or something more along the lines of 
session.IssueDeletion(), since Save() still needs to be called after it.

Currently to delete a session, you need to do:

   // ...
   session.Options = &sessions.Options{MaxAge: -1}
   session.Save(r, w)

Original issue reported on code.google.com by rodrigo.moraes on 3 May 2012 at 12:14

GoogleCodeExporter commented 9 years ago
Also may be good to add ability to delete session from store (filestore/mongodb 
and others). 

Original comment by v...@selfip.ru on 18 Jun 2012 at 2:07

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
It could be session.Clear()

Original comment by fio...@gmail.com on 6 Apr 2013 at 7:54

GoogleCodeExporter commented 9 years ago
By the way, one might also set the Path to delete the cookie:

    session.Options = &sessions.Options{MaxAge: -1, Path: "/"}

Or use net/http directly:

    http.SetCookie(w, &http.Cookie{Name: "sess", MaxAge: -1, Path: "/"})

Original comment by fio...@gmail.com on 8 Apr 2013 at 8:59

GoogleCodeExporter commented 9 years ago
I would vote for Destroy() since "Destroy" is on par with session lingo

Original comment by styler1...@gmail.com on 23 Jul 2014 at 4:40

GoogleCodeExporter commented 9 years ago
I agree, it should be easier to destroy a session.

Original comment by tsrwe...@gmail.com on 26 Jul 2014 at 11:53