Explorar o código

Merge branch 'dev/v4.8.47_ws' of qmx/jy into feature/v4.8.47

wangshan %!s(int64=2) %!d(string=hai) anos
pai
achega
f939c50428

+ 1 - 0
src/jfw/modules/app/src/app/front/login.go

@@ -866,6 +866,7 @@ func (l *Login) SignOut() {
 	})
 	go config.Middleground.PowerCheckCenter.DelCheckRedis("10000", positionId)
 	ClearSession(l.Session())
+	go jyutil.ChangeLoginCookie(0, 5, l.ResponseWriter, "isLogin", "1")
 	l.ServeJson(map[string]interface{}{
 		"status": status,
 	})

+ 1 - 8
src/jfw/modules/app/src/app/front/tags.go

@@ -10,7 +10,6 @@ import (
 	"jy/src/jfw/modules/app/src/app/jyutil"
 	"jy/src/jfw/modules/app/src/jfw/config"
 	"log"
-	"net/http"
 	"strconv"
 	"strings"
 )
@@ -101,13 +100,7 @@ func init() {
 func (tg *Tags) TagsIndex(first, types, name string) error {
 	defer qu.Catch()
 	if userId, _ := tg.GetSession("userId").(string); userId != "" {
-		tg.SetCookie(&http.Cookie{
-			Name:     "isLogin",
-			Value:    "1",
-			Path:     "/",
-			HttpOnly: false,
-			MaxAge:   600, //十分钟
-		})
+		jyutil.ChangeLoginCookie(1, 5, tg.ResponseWriter, "isLogin", "1")
 		return tg.Redirect("/jyapp/jylab/mainSearch")
 	}
 	if !firstList[first] {

+ 28 - 0
src/jfw/modules/app/src/app/jyutil/util.go

@@ -2,10 +2,12 @@ package jyutil
 
 import (
 	util "app.yhyue.com/moapp/jybase/common"
+	"app.yhyue.com/moapp/jybase/go-xweb/httpsession"
 	"app.yhyue.com/moapp/jypkg/compatible"
 	"app.yhyue.com/moapp/jypkg/public"
 	"encoding/json"
 	. "jy/src/jfw/modules/app/src/jfw/config"
+	"net/http"
 	"reflect"
 	"regexp"
 	"sort"
@@ -247,3 +249,29 @@ func Handle(data []interface{}, host string) []AdInfo {
 	}
 	return res
 }
+
+func ChangeLoginCookie(status, timeOut int, w http.ResponseWriter, name, value string) {
+	switch status {
+	case 1:
+		http.SetCookie(w, &http.Cookie{
+			Name:     name,
+			Value:    value,
+			Path:     "/",
+			HttpOnly: false,
+			MaxAge:   timeOut,
+			Expires:  time.Now().Add(time.Duration(timeOut)),
+			Domain:   httpsession.Domain,
+		})
+	default:
+		http.SetCookie(w, &http.Cookie{
+			Name:     name,
+			Value:    value,
+			Path:     "/",
+			HttpOnly: false,
+			MaxAge:   -1,
+			Expires:  time.Now().Add(-1),
+			Domain:   httpsession.Domain,
+		})
+
+	}
+}