|
@@ -136,15 +136,19 @@ func GetWsByCode(param []string) bool {
|
|
|
if infoData != nil {
|
|
|
baseUserId := qutil.Int64All(session.Get("base_user_id"))
|
|
|
if ok, err := redis.Exists("newother", fmt.Sprintf(jyutil.KeepLoginTimeKey, src)); ok && err == nil && baseUserId > 0 {
|
|
|
- infoData[jyutil.KeepLoginCookieName] = encrypt.SE.EncodeString(strconv.FormatInt(baseUserId, 10))
|
|
|
+ infoData["cValue"] = encrypt.SE.EncodeString(strconv.FormatInt(baseUserId, 10))
|
|
|
+ infoData["cName"] = jyutil.KeepLoginCookieName
|
|
|
expiresHour := qutil.IntAll(Sysconfig["setSessionTimeout"])
|
|
|
expires := time.Now().Add(time.Duration(expiresHour) * time.Hour)
|
|
|
- infoData["expires"] = expires
|
|
|
+ infoData["expires"] = expires.Format("2006-01-02 15:04:05")
|
|
|
//往cookie加入标识 保证用户登录状态延期
|
|
|
- //if ok := redis.Del("newother", fmt.Sprintf(jyutil.KeepLoginTimeKey, src)); !ok {
|
|
|
- // log.Println(fmt.Sprintf("%d 清除用户登录延期标识 异常", baseUserId))
|
|
|
- //}
|
|
|
- //jyutil.SetCookieValueForAutoLogin(wss.Conn.W, baseUserId)
|
|
|
+ if ok := redis.Del("newother", fmt.Sprintf(jyutil.KeepLoginTimeKey, src)); !ok {
|
|
|
+ log.Println(fmt.Sprintf("%d 清除用户登录延期标识 异常", baseUserId))
|
|
|
+ }
|
|
|
+ //
|
|
|
+ //收到webSocket消息后,您无法设置cookie.一旦建立了webSocket连接,它就是一个开放的TCP套接字,协议不再是http,因此没有内置的方式来交换cookie.
|
|
|
+ //jyutil.SetCookieValueForAutoLogin(wss.Conn.W, baseUserId) 不可用
|
|
|
+ //您可以将自己的webSocket消息发送回客户端,告知它设置cookie,然后在客户端中侦听该消息,当它收到该消息时,它可以在浏览器中设置cookie.
|
|
|
}
|
|
|
}
|
|
|
if wss.Conn == nil {
|