MCPcopy Create free account
hub / github.com/devfeel/dotweb / NewSessionManager

Function NewSessionManager

session/session.go:107–125  ·  view source on GitHub ↗

NewSessionManager create new seesion manager

(gcLifetime int64, appLog logger.AppLog, config *StoreConfig)

Source from the content-addressed store, hash-verified

105
106// NewSessionManager create new seesion manager
107func NewSessionManager(gcLifetime int64, appLog logger.AppLog, config *StoreConfig) (*SessionManager, error) {
108 if gcLifetime <= 0 {
109 gcLifetime = DefaultSessionGCLifeTime
110 }
111 if config.CookieName == "" {
112 config.CookieName = DefaultSessionCookieName
113 }
114 manager := &SessionManager{
115 store: GetSessionStore(config),
116 appLog: appLog,
117 GCLifetime: gcLifetime,
118 storeConfig: config,
119 }
120 // enable GC
121 go func() {
122 time.AfterFunc(time.Duration(manager.GCLifetime)*time.Second, func() { manager.GC() })
123 }()
124 return manager, nil
125}
126
127// NewSessionID create new session id with DefaultSessionLength
128func (manager *SessionManager) NewSessionID() string {

Callers 1

NewDefaultSessionManagerFunction · 0.85

Calls 2

GCMethod · 0.95
GetSessionStoreFunction · 0.85

Tested by

no test coverage detected