Dgraph & MongoDB implementations for kataras/go-sessions.
For a full documentation of the library see the original repository.
Full examples can be found in the examples folder.
To include mongostore
run
go get github.com/bh90210/go-sessions-stores/mongostore
// replace with your running mongo server settings:
cred := options.Credential{
AuthSource: "admin",
Username: "user",
Password: "password",
}
clientOpts := options.Client().ApplyURI("mongodb://127.0.0.1:27017").SetAuth(cred)
db, _ := mongostore.New(clientOpts, "sessions")
sess := sessions.New(sessions.Config{Cookie: "sessionscookieid"})
sess.UseDatabase(db)
To include dgraphstore
run
go get github.com/bh90210/go-sessions-stores/dgraphstore
// replace with your server settings:
conn, _ := grpc.Dial("127.0.0.1:9080", grpc.WithInsecure())
db, _ := dgraphstore.NewFromDB(conn)
sess := sessions.New(sessions.Config{Cookie: "sessionscookieid"})
sess.UseDatabase(db)