martini-contrib / Sessions
Licence: mit
Martini handler that provides a Session service.
Stars: ✭ 72
Programming Languages
go
31211 projects - #10 most used programming language
sessions
Martini middleware/handler for easy session management.
Usage
package main
import (
"github.com/go-martini/martini"
"github.com/martini-contrib/sessions"
)
func main() {
m := martini.Classic()
store := sessions.NewCookieStore([]byte("secret123"))
m.Use(sessions.Sessions("my_session", store))
m.Get("/set", func(session sessions.Session) string {
session.Set("hello", "world")
return "OK"
})
m.Get("/get", func(session sessions.Session) string {
v := session.Get("hello")
if v == nil {
return ""
}
return v.(string)
})
m.Run()
}
Authors
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].