Skip to content

Instantly share code, notes, and snippets.

@ScullWM
Last active November 28, 2016 23:02
Show Gist options
  • Save ScullWM/a8adaca8e2c114be2352db4c16d3202d to your computer and use it in GitHub Desktop.
Save ScullWM/a8adaca8e2c114be2352db4c16d3202d to your computer and use it in GitHub Desktop.
const cookieName = "mycookiename"
var hashKey = []byte(securecookie.GenerateRandomKey(32))
var blockKey = []byte(securecookie.GenerateRandomKey(32))
var sc = securecookie.New(hashKey, blockKey)
func ReadCookieHandler(r *http.Request) bool {
if cookie, err := r.Cookie(cookieName); err == nil {
value := make(map[string]string)
if err = sc.Decode(cookieName, cookie.Value, &value); err == nil {
return true
}
}
return false
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment