diff options
-rw-r--r-- | store.go | 18 |
1 files changed, 18 insertions, 0 deletions
@@ -33,6 +33,8 @@ type Store interface { // Save should persist session to the underlying store implementation. Save(ctx echo.Context, s *Session) error + // Remove server-side data + Remove(sessionID string) error } // IDGenerator session id generator @@ -132,6 +134,10 @@ func (s *CookieStore) Save(ctx echo.Context, session *Session) error { return nil } +func (s *CookieStore) Remove(sessionID string) error { + return nil +} + // MaxAge sets the maximum age for the store and the underlying cookie // implementation. Individual sessions can be deleted by setting Options.MaxAge // = -1 for that session. @@ -252,6 +258,18 @@ func (s *FilesystemStore) Save(ctx echo.Context, session *Session) error { return nil } +func (s *FilesystemStore) Remove(sessionID string) error { + if len(sessionID) == 0 { + return nil + } + filename := filepath.Join(s.path, "session_"+sessionID) + fileMutex.RLock() + defer fileMutex.RUnlock() + + err := os.Remove(filename) + return err +} + // delete session file func (s *FilesystemStore) erase(session *Session) error { if len(session.ID) == 0 { |