func NewCookieSessionStore(name, secret string, defaultDuration time.Duration) CookieSessionStore { return CookieSessionStore{ CookieSigner: goanna.NewCookieSigner(secret), CookieName: name, DefaultDuration: defaultDuration, } }
func NewSignedCookieSessionFinder(name string, key []byte, defaultDuration time.Duration, secure bool) goanna.SessionFinder { ss := signedCookieSessionHandler{ CookieSigner: goanna.NewCookieSigner(key), CookieName: name, DefaultDuration: defaultDuration, Secure: secure, } return func(r *goanna.Request) goanna.Session { return ss.GetSession(r) } }
func ExampleCookieSigner() { signer := goanna.NewCookieSigner([]byte("secret")) cookie := http.Cookie{ Name: "foo", Value: "bar", } fmt.Println(cookie.Value) // bar signer.EncodeCookie(&cookie) fmt.Println(cookie.Value) // aMcN2wzx4XLp9w3CPrwNb6PtTzECzkMPIiEfDqVDk4k=.bar signer.DecodeCookie(&cookie) fmt.Println(cookie.Value) // bar }