func SessionUser(newUser func() User) martini.Handler {
	return func(s sessions.Session, c martini.Context, l *log.Logger) {
		userId := s.Get(SessionKey)
		user := newUser()
		if userId != nil {
			err := user.GetById(userId)
			if err != nil {
				l.Printf("Login Error: %v\n", err)
			} else {
				user.Login()
			}
		}
		c.MapTo(user, (*User)(nil))
	}
}
SessionUser will try to read a unique user ID out of the session. Then it tries
to populate an anonymous user object from the database based on that ID. If this
is successful, the valid user is mapped into the context. Otherwise the anonymous
user is mapped into the contact.
The newUser() function should provide a valid 0value structure for the caller's
user type.
package sessionauth
import (
	"fmt"
	"github.com/go-martini/martini"
	"github.com/martini-contrib/render"
	"github.com/martini-contrib/sessions"
	"log"
	"net/http"
)
var (
	RedirectUrl string = "/login"
	RedirectParam string = "next"
	SessionKey string = "AUTHUNIQUEID"
)
type User interface {
	IsAuthenticated() bool
	Login()
	Logout()
	UniqueId() interface{}
	GetById(id interface{}) error
}