-
Notifications
You must be signed in to change notification settings - Fork 3
/
doc.go
41 lines (31 loc) · 1.03 KB
/
doc.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/*
Package mongostore follows the Gorilla Session implementation
Reason for creation over using an existing library
When the MongoDB database the sessions were being stored in was not reachable
especially in the event of a database cycle other libraries would not
restablish the database session; this library will.
Example Usage:
func foo(w http.ResponseWriter, r *http.Request) {
// Coonect to MongoDB
dbSess, err := mgo.Dial("localhost")
if err != nil {
panic(err)
}
defer dbSess.Close()
store := mongostore.New(dbSess, "sessions", 3600, true,
[]byte("secret-key"))
// Get a session.
session, err := store.Get(r, "session-key")
if err != nil {
log.Println(err.Error())
}
// Add a value.
session.Values["foo"] = "bar"
// Save.
if err = sessions.Save(r, w); err != nil {
log.Printf("Error saving session: %v", err)
}
fmt.Fprintln(w, "ok")
}
*/
package mongostore