wangshan 1 Minggu lalu
induk
melakukan
fd9f980802
1 mengubah file dengan 23 tambahan dan 18 penghapusan
  1. 23 18
      src/jfw/filter/cookie.go

+ 23 - 18
src/jfw/filter/cookie.go

@@ -1,30 +1,35 @@
 package filter
 package filter
 
 
 import (
 import (
-	"app.yhyue.com/moapp/jybase/go-xweb/httpsession"
-	"app.yhyue.com/moapp/jypkg/common/src/qfw/util/jy"
-	fx "app.yhyue.com/moapp/jypkg/filter/xweb"
-	"net/http"
-	"strings"
+    "app.yhyue.com/moapp/jybase/go-xweb/httpsession"
+    "app.yhyue.com/moapp/jypkg/common/src/qfw/util/jy"
+    fx "app.yhyue.com/moapp/jypkg/filter/xweb"
+    "log"
+    "net/http"
+    "strings"
 )
 )
 
 
 // CookieInfo 信息
 // CookieInfo 信息
 type CookieInfo struct {
 type CookieInfo struct {
-	W       http.ResponseWriter
-	R       *http.Request
-	IsLogin bool
-	Session *httpsession.Session
+    W       http.ResponseWriter
+    R       *http.Request
+    IsLogin bool
+    Session *httpsession.Session
 }
 }
 
 
 // Do 继承过滤器方法
 // Do 继承过滤器方法
 func (ci *CookieInfo) Do() {
 func (ci *CookieInfo) Do() {
-	if crr := ci.R.Referer(); !ci.IsLogin && crr != "" {
-		if strings.Contains(crr, "cooperate") {
-			match := strings.Split(crr, "cooperate/")
-			if len(match) > 1 {
-				fx.SetVisitSource(ci.Session, match[1])
-				jy.SetCookieValue(ci.W, jy.ChannelCookieName, match[1], 7*24*60*60)
-			}
-		}
-	}
+    //判断 cookie 是否有seo referer标识
+    if seoRefer, err := ci.R.Cookie("SeoRefer"); err != nil && seoRefer.Value != "" {
+        log.Println("-----------seoRefer------------", seoRefer)
+    }
+    if crr := ci.R.Referer(); !ci.IsLogin && crr != "" {
+        if strings.Contains(crr, "cooperate") {
+            match := strings.Split(crr, "cooperate/")
+            if len(match) > 1 {
+                fx.SetVisitSource(ci.Session, match[1])
+                jy.SetCookieValue(ci.W, jy.ChannelCookieName, match[1], 7*24*60*60)
+            }
+        }
+    }
 }
 }