Golang net/http.Request.AddCookie() and Cookie() functions example
package net/http
Golang net/http.Request.AddCookie() and Cookie() functions usage example
func someFunction(w http.ResponseWriter, r *http.Request) {
..
c, err := r.Cookie("timevisited")
expire := time.Now().AddDate(0, 0, 1)
cookieMonster := &http.Cookie{
Name: "timevisited",
Expires: expire,
Value: strconv.FormatInt(time.Now().Unix(), 10),
}
r.AddCookie(cookieMonster)
...
}
References :
Advertisement
Something interesting
Tutorials
+25.9k Golang : How to read integer value from standard input ?
+7k Golang : Levenshtein distance example
+18.4k Golang : How to remove certain lines from a file
+19.6k Golang : Get current URL example
+19.2k Golang : Populate dropdown with html/template example
+11.5k CodeIgniter : Import Linkedin data
+20.3k Golang : Check if os.Stdin input data is piped or from terminal
+6.1k Golang : Scan forex opportunities by Bollinger bands
+8.2k Prevent Write failed: Broken pipe problem during ssh session with screen command
+17.9k Golang : Login and logout a user after password verification and redirect example
+8.4k Golang : Generate Datamatrix barcode
+7.5k Golang : Handling Yes No Quit query input