
Product
Introducing License Overlays: Smarter License Management for Real-World Code
Customize license detection with Socket’s new license overlays: gain control, reduce noise, and handle edge cases with precision.
github.com/irfanhabib/mysqlstore
Gorilla's Session Store Implementation for MySQL
Run go get github.com/srinathgs/mysqlstore
from command line. Gets installed in $GOPATH
NewMysqlStore
takes the following paramaters
endpoint - A sql.Open style endpoint
tableName - table where sessions are to be saved. Required fields are created automatically if the table doesnot exist.
path - path for Set-Cookie header
maxAge
codecs
Internally, mysqlstore
uses this MySQL driver.
e.g.,
package main
import (
"fmt"
"github.com/srinathgs/mysqlstore"
"net/http"
)
var store *mysqlstore.MySQLStore
func sessTest(w http.ResponseWriter, r *http.Request) {
session, err := store.Get(r, "foobar")
session.Values["bar"] = "baz"
session.Values["baz"] = "foo"
err = session.Save(r, w)
fmt.Printf("%#v\n", session)
fmt.Println(err)
}
func main() {
store, err := mysqlstore.NewMySQLStore("UN:PASS@tcp(<IP>:<PORT>)/<DB>?parseTime=true&loc=Local", <tablename>, "/", 3600, []byte("<SecretKey>"))
if err != nil {
panic(err)
}
defer store.Close()
http.HandleFunc("/", sessTest)
http.ListenAndServe(":8080", nil)
}
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Customize license detection with Socket’s new license overlays: gain control, reduce noise, and handle edge cases with precision.
Product
Socket now supports Rust and Cargo, offering package search for all users and experimental SBOM generation for enterprise projects.
Product
Socket’s precomputed reachability slashes false positives by flagging up to 80% of vulnerabilities as irrelevant, with no setup and instant results.