go-skeletor/vendor/github.com/martini-contrib/sessions
Arnaud Fornerot 0c861770a8 first commit 2021-11-02 11:25:21 +01:00
..
LICENSE first commit 2021-11-02 11:25:21 +01:00
README.md first commit 2021-11-02 11:25:21 +01:00
cookie_store.go first commit 2021-11-02 11:25:21 +01:00
redis_store.go first commit 2021-11-02 11:25:21 +01:00
sessions.go first commit 2021-11-02 11:25:21 +01:00
wercker.yml first commit 2021-11-02 11:25:21 +01:00

README.md

sessions wercker status

Martini middleware/handler for easy session management.

API Reference

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