Skip to content

bh90210/go-sessions-stores

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-sessions-stores

Go Report

Dgraph & MongoDB implementations for kataras/go-sessions.

How to use

For a full documentation of the library see the original repository.

Full examples can be found in the examples folder.

Mongo

Mongo Reference

To include mongostore run

go get github.com/bh90210/go-sessions-stores/mongostore

Example

	// 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)

Dgraph

Dgraph Reference

To include dgraphstore run

go get github.com/bh90210/go-sessions-stores/dgraphstore

Example

	// 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)