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
+9.6k Golang : Sort and reverse sort a slice of floats
+6.5k Golang : Convert an executable file into []byte example
+4.7k MariaDB/MySQL : Form select statement or search query with Chinese characters
+12.7k Golang : Send data to /dev/null a.k.a blackhole with ioutil.Discard
+13.7k Golang : Tutorial on loading GOB and PEM files
+6.1k Fix ERROR 2003 (HY000): Can't connect to MySQL server on 'IP address' (111)
+5.8k Cash Flow : 50 days to pay your credit card debt
+14.3k Golang : Recombine chunked files example
+9.7k Golang : Load ASN1 encoded DSA public key PEM file example
+39.2k Golang : How to read CSV file
+5.8k Golang : Fix opencv.LoadHaarClassifierCascade The node does not represent a user object error