|
@@ -2,6 +2,7 @@ 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"
|
|
@@ -251,31 +252,31 @@ func Handle(data []interface{}, host string) []AdInfo {
|
|
|
return res
|
|
|
}
|
|
|
|
|
|
-func ChangeLoginCookie(status, timeOut int, w http.ResponseWriter, r *http.Request, name string) {
|
|
|
- switch status {
|
|
|
- case 1:
|
|
|
- http.SetCookie(w, &http.Cookie{
|
|
|
- Name: name,
|
|
|
- Value: strconv.Itoa(status),
|
|
|
- Path: "/",
|
|
|
- HttpOnly: false,
|
|
|
- MaxAge: timeOut,
|
|
|
- Expires: time.Now().Add(time.Duration(timeOut)),
|
|
|
- })
|
|
|
- default:
|
|
|
- http.SetCookie(w, &http.Cookie{
|
|
|
- Name: name,
|
|
|
- Value: strconv.Itoa(status),
|
|
|
- Path: "/",
|
|
|
- HttpOnly: false,
|
|
|
- MaxAge: timeOut,
|
|
|
- Expires: time.Now().Add(time.Duration(timeOut)),
|
|
|
- })
|
|
|
- log.Println("----清除 islogin cookie-----")
|
|
|
- }
|
|
|
+func ChangeLoginCookie(timeOut int, w http.ResponseWriter, r *http.Request, name string) (c int) {
|
|
|
v, err := r.Cookie(name)
|
|
|
- log.Println(status, "-------------", err)
|
|
|
if err == nil {
|
|
|
- log.Println("---islogin cookie---:", v.Name, "--", v.Value, "--", v.Expires, "--", v.Domain, "--", v.Path, "--")
|
|
|
+ c, _ = strconv.Atoi(v.Value)
|
|
|
+ } else {
|
|
|
+ hCookie := r.Header.Get("Cookie")
|
|
|
+ if hCookie != "" && strings.Contains(hCookie, name) {
|
|
|
+ for _, hc := range strings.Split(hCookie, ";") {
|
|
|
+ if len(strings.Split(hc, "=")) > 1 {
|
|
|
+ c, _ = strconv.Atoi(strings.Split(hc, "=")[1])
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
+ c++
|
|
|
+ log.Println(c, "-------------", err)
|
|
|
+ http.SetCookie(w, &http.Cookie{
|
|
|
+ Name: name,
|
|
|
+ Value: strconv.Itoa(c),
|
|
|
+ Path: "/",
|
|
|
+ HttpOnly: false,
|
|
|
+ MaxAge: timeOut,
|
|
|
+ Expires: time.Now().Add(time.Duration(timeOut)),
|
|
|
+ Domain: httpsession.Domain,
|
|
|
+ })
|
|
|
+ return
|
|
|
}
|