fully convert redis over to custom key value store type
This commit is contained in:
@@ -12,7 +12,7 @@ import (
|
||||
const SessionCookieName = "session_token"
|
||||
|
||||
type SessionManager struct {
|
||||
store store.Store[string, *SessionData]
|
||||
store store.KeyValueStore[*SessionData]
|
||||
}
|
||||
|
||||
var instance *SessionManager
|
||||
@@ -37,12 +37,12 @@ func (manager *SessionManager) SetStoreType(storeType StoreType) {
|
||||
switch storeType {
|
||||
case InMemory:
|
||||
{
|
||||
manager.store = NewMemoryStore()
|
||||
// manager.store = NewMemoryStore()
|
||||
break
|
||||
}
|
||||
case Redis:
|
||||
{
|
||||
manager.store = NewRedisStore()
|
||||
manager.store = store.NewRedisStore[*SessionData]()
|
||||
break
|
||||
}
|
||||
}
|
||||
@@ -72,10 +72,10 @@ func (manager *SessionManager) CreateSession(userID string) (cookie *http.Cookie
|
||||
Name: SessionCookieName,
|
||||
Value: token,
|
||||
Path: "/",
|
||||
HttpOnly: true, // Essential: prevents JS access
|
||||
Secure: true, // Set to TRUE in production (HTTPS)
|
||||
HttpOnly: true,
|
||||
Secure: true,
|
||||
SameSite: http.SameSiteLaxMode,
|
||||
MaxAge: 3600, // 1 hour
|
||||
MaxAge: 3600,
|
||||
}
|
||||
return newCookie, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user