Add iris.DestroySessionByID(string) and iris.DestroyAllSessions() as requested. Read HISTORY.md

c9d94b7b44
This commit is contained in:
Gerasimos (Makis) Maropoulos 2017-01-08 06:18:02 +02:00
parent bcc35c11ca
commit 5daa3d6fa7
2 changed files with 19 additions and 1 deletions

View File

@ -4,7 +4,7 @@
## 6.0.4 -> 6.0.5 ## 6.0.4 -> 6.0.5
- Add `iris.DestroySessionByID(string)` and `iris.DestroyAllSessions()` functions as requested by a community member in the [chat]https://kataras.rocket.chat/channel/iris): - Add `iris.DestroySessionByID(string)` and `iris.DestroyAllSessions()` functions as requested by a community member in the [chat](https://kataras.rocket.chat/channel/iris):
```go ```go
// DestroySessionByID removes the session entry // DestroySessionByID removes the session entry

18
iris.go
View File

@ -154,6 +154,8 @@ type (
ReleaseCtx(*Context) ReleaseCtx(*Context)
CheckForUpdates(bool) CheckForUpdates(bool)
UseSessionDB(sessions.Database) UseSessionDB(sessions.Database)
DestroySessionByID(sid string)
DestroyAllSessions()
UseSerializer(string, serializer.Serializer) UseSerializer(string, serializer.Serializer)
UseTemplate(template.Engine) *template.Loader UseTemplate(template.Engine) *template.Loader
UsePreRender(PreRender) UsePreRender(PreRender)
@ -791,6 +793,15 @@ func (s *Framework) UseSessionDB(db sessions.Database) {
s.sessions.UseDatabase(db) s.sessions.UseDatabase(db)
} }
// DestroySessionByID removes the session entry
// from the server-side memory (and database if registered).
// Client's session cookie will still exist but it will be reseted on the next request.
//
// It's safe to use it even if you are not sure if a session with that id exists.
func DestroySessionByID(sid string) {
Default.DestroySessionByID(sid)
}
// DestroySessionByID removes the session entry // DestroySessionByID removes the session entry
// from the server-side memory (and database if registered). // from the server-side memory (and database if registered).
// Client's session cookie will still exist but it will be reseted on the next request. // Client's session cookie will still exist but it will be reseted on the next request.
@ -800,6 +811,13 @@ func (s *Framework) DestroySessionByID(sid string) {
s.sessions.DestroyByID(sid) s.sessions.DestroyByID(sid)
} }
// DestroyAllSessions removes all sessions
// from the server-side memory (and database if registered).
// Client's session cookie will still exist but it will be reseted on the next request.
func DestroyAllSessions() {
Default.DestroyAllSessions()
}
// DestroyAllSessions removes all sessions // DestroyAllSessions removes all sessions
// from the server-side memory (and database if registered). // from the server-side memory (and database if registered).
// Client's session cookie will still exist but it will be reseted on the next request. // Client's session cookie will still exist but it will be reseted on the next request.