NewSessionManager create new seesion manager
(gcLifetime int64, appLog logger.AppLog, config *StoreConfig)
| 105 | |
| 106 | // NewSessionManager create new seesion manager |
| 107 | func 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 |
| 128 | func (manager *SessionManager) NewSessionID() string { |
no test coverage detected