21 lines
373 B
Go
21 lines
373 B
Go
|
package web
|
||
|
|
||
|
import (
|
||
|
"database/sql"
|
||
|
|
||
|
"github.com/alexedwards/scs/postgresstore"
|
||
|
"github.com/alexedwards/scs/v2"
|
||
|
)
|
||
|
|
||
|
func NewSessionsManager(dataSourceName string) (*scs.SessionManager, error) {
|
||
|
db, err := sql.Open("postgres", dataSourceName)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
|
||
|
sessions := scs.New()
|
||
|
sessions.Store = postgresstore.New(db)
|
||
|
|
||
|
return sessions, nil
|
||
|
}
|