| @@ -106,6 +106,13 @@ func cookieCreate(name, value string, expireInSeconds int) (ret http.Cookie) { | |||
| return | |||
| } | |||
| //set to "" and make it expire | |||
| func cookieClear(name string) (ret http.Cookie) { | |||
| expiration := time.Unix(0, 0) //Epoc | |||
| ret = http.Cookie{Name: name, Value: "", Expires: expiration} | |||
| return | |||
| } | |||
| func crmCreateNewAnonymousLeadByHTTPRequest(r *http.Request) (info crmdLead) { | |||
| info.FirstName = "Anonymous" | |||
| info.LastName = "User " + r.RemoteAddr | |||
| @@ -230,6 +237,7 @@ func setTrackingCookieAndRecirect(w http.ResponseWriter, r *http.Request) { | |||
| if ok { | |||
| log.Println("setlead cookie :" + leadID[0]) | |||
| cookie := cookieFromLeadID(leadID[0]) | |||
| log.Println(cookie) | |||
| http.SetCookie(w, &cookie) | |||
| } else { | |||
| cookie := crmpixelCookie(r) | |||
| @@ -248,9 +256,16 @@ func setTrackingCookieAndRecirect(w http.ResponseWriter, r *http.Request) { | |||
| if k == "lid" || k == "url" || k == "expire" || k == "nonce" || k == "signature" || k == "timestamp" { //skip lead id and URL and expire | |||
| continue | |||
| } | |||
| log.Printf("set cookie %s=%s", k, v) | |||
| cookie := cookieCreate(k, v[0], expire) | |||
| http.SetCookie(w, &cookie) | |||
| if v[0] != "" { | |||
| log.Printf("set cookie %s=%s", k, v) | |||
| cookie := cookieCreate(k, v[0], expire) | |||
| http.SetCookie(w, &cookie) | |||
| } else { //clear cook | |||
| log.Printf("clear cookie %s=%s", k, v) | |||
| cookie := cookieClear(k) | |||
| http.SetCookie(w, &cookie) | |||
| } | |||
| } | |||
| //perform redirect | |||