From 93640f949cfeb2399ca73fdb0352738c66a7c00b Mon Sep 17 00:00:00 2001 From: Patrick Peng Sun Date: Sun, 16 Jul 2017 19:48:46 +1000 Subject: [PATCH] get general cookie value by their name. --- crmpixel.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/crmpixel.go b/crmpixel.go index 188210e..c437f22 100644 --- a/crmpixel.go +++ b/crmpixel.go @@ -57,8 +57,12 @@ func crmpixelCookie(r *http.Request) (ret http.Cookie) { } func getLeadIDFromCookie(r *http.Request) (leadID string, ok bool) { + return cookieVerifyAndGet(r, cookLeadID) +} + +func cookieVerifyAndGet(r *http.Request, name string) (value string, ok bool) { ok = false - cookie, leadok := r.Cookie(cookLeadID) //crm lead + cookie, leadok := r.Cookie(name) if leadok != nil { return } @@ -73,8 +77,9 @@ func getLeadIDFromCookie(r *http.Request) (leadID string, ok bool) { return } ok = true - leadID = s[0] + value = s[0] return + } func createNewCookie(r *http.Request) (ret http.Cookie, info crmdLead) {