diff options
author | Hank Shen <swhbox@foxmail.com> | 2021-05-19 06:34:31 +0300 |
---|---|---|
committer | Hank Shen <swhbox@foxmail.com> | 2021-05-19 06:34:31 +0300 |
commit | ccf4afe08439ae1d07ee1f32ad69b6b527f8e782 (patch) | |
tree | 3219223f2c5e65d71e461a4cf65318b945813172 | |
parent | 86db493d73044ebad01ac419dd380f45298bdd35 (diff) |
updatev0.1.0
-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 { |