package
0.0.0-20140208234550-8ce6181c2609
Repository: https://github.com/codegangsta/martini-contrib.git
Documentation: pkg.go.dev

# README

sessions

Martini middleware/handler for easy session management.

API Reference

Usage

package main

import (
  "github.com/codegangsta/martini"
  "github.com/codegangsta/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

# Functions

NewCookieStore returns a new CookieStore.
Sessions is a Middleware that maps a session.Session service into the Martini handler chain.

# Structs

Options stores configuration for a session or session store.

# Interfaces

CookieStore is an interface that represents a Cookie based storage for Sessions.
Session stores the values and optional configuration for a session.
Store is an interface for custom session stores.