Skip to content

Gorilla's Session store implementation with MongoDB. Fork from original to support deprecated mgo library.

Notifications You must be signed in to change notification settings

TykTechnologies/mongostore

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mongostore

Gorilla's Session store implementation with MongoDB using the legacy (unmantained) mgo library

This repository is meant to give some backwards compatibility to some projects that can't upgrade to other MongoDB driver at the moment. If you need/want to use the more up to date mgo library check the original library from where this one derives.

Requirements

Depends on the unmantained mgo library.

Installation

go get github.com/TykTechnologies/mongostore

Documentation

Available on godoc.org.

Example

    func foo(rw http.ResponseWriter, req *http.Request) {
        // Fetch new store.
        dbsess, err := mgo.Dial("localhost")
        if err != nil {
            panic(err)
        }
        defer dbsess.Close()

        store := mongostore.NewMongoStore(dbsess.DB("test").C("test_session"), 3600, true,
            []byte("secret-key"))

        // Get a session.
        session, err := store.Get(req, "session-key")
        if err != nil {
            log.Println(err.Error())
        }

        // Add a value.
        session.Values["foo"] = "bar"

        // Save.
        if err = sessions.Save(req, rw); err != nil {
            log.Printf("Error saving session: %v", err)
        }

        fmt.Fprintln(rw, "ok")
    }

About

Gorilla's Session store implementation with MongoDB. Fork from original to support deprecated mgo library.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages