diff --git a/HISTORY.md b/HISTORY.md index efdc4bc7..83b89403 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -4,7 +4,7 @@ ## 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 // DestroySessionByID removes the session entry diff --git a/iris.go b/iris.go index 4adb46c8..00361ce6 100644 --- a/iris.go +++ b/iris.go @@ -154,6 +154,8 @@ type ( ReleaseCtx(*Context) CheckForUpdates(bool) UseSessionDB(sessions.Database) + DestroySessionByID(sid string) + DestroyAllSessions() UseSerializer(string, serializer.Serializer) UseTemplate(template.Engine) *template.Loader UsePreRender(PreRender) @@ -791,6 +793,15 @@ func (s *Framework) UseSessionDB(db sessions.Database) { 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 // 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. @@ -800,6 +811,13 @@ func (s *Framework) DestroySessionByID(sid string) { 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 // 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.