Bladeren bron

clear cookie

master
Patrick Peng Sun 8 jaren geleden
bovenliggende
commit
cf56c1ccf0
1 gewijzigde bestanden met toevoegingen van 18 en 3 verwijderingen
  1. +18
    -3
      crmpixel.go

+ 18
- 3
crmpixel.go Bestand weergeven

return 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) { func crmCreateNewAnonymousLeadByHTTPRequest(r *http.Request) (info crmdLead) {
info.FirstName = "Anonymous" info.FirstName = "Anonymous"
info.LastName = "User " + r.RemoteAddr info.LastName = "User " + r.RemoteAddr
if ok { if ok {
log.Println("setlead cookie :" + leadID[0]) log.Println("setlead cookie :" + leadID[0])
cookie := cookieFromLeadID(leadID[0]) cookie := cookieFromLeadID(leadID[0])
log.Println(cookie)
http.SetCookie(w, &cookie) http.SetCookie(w, &cookie)
} else { } else {
cookie := crmpixelCookie(r) cookie := crmpixelCookie(r)
if k == "lid" || k == "url" || k == "expire" || k == "nonce" || k == "signature" || k == "timestamp" { //skip lead id and URL and expire if k == "lid" || k == "url" || k == "expire" || k == "nonce" || k == "signature" || k == "timestamp" { //skip lead id and URL and expire
continue 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 //perform redirect

Laden…
Annuleren
Opslaan