Skip to content

Instantly share code, notes, and snippets.

@lettergram
Created March 18, 2015 23:58
Show Gist options
  • Save lettergram/8ab36d91e21720d11cd0 to your computer and use it in GitHub Desktop.
Save lettergram/8ab36d91e21720d11cd0 to your computer and use it in GitHub Desktop.
func LoginCookie(username string) http.Cookie {
cookieValue := username + ":" + codify.SHA(username+strconv.Itoa(rand.Intn(100000000)))
expire := time.Now().AddDate(0, 0, 1)
return http.Cookie{Name: "SessionID", Value: cookieValue, Expires: expire, HttpOnly: true}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment