(ctx *gin.Context, visitToken string, force bool)
| 713 | } |
| 714 | |
| 715 | func (uc *UserController) setVisitCookies(ctx *gin.Context, visitToken string, force bool) { |
| 716 | if !force { |
| 717 | cookie, _ := ctx.Cookie(constant.UserVisitCookiesCacheKey) |
| 718 | // If the cookie is the same as the visitToken, no need to set it again |
| 719 | if cookie == visitToken { |
| 720 | return |
| 721 | } |
| 722 | } |
| 723 | general, err := uc.siteInfoCommonService.GetSiteGeneral(ctx) |
| 724 | if err != nil { |
| 725 | log.Errorf("get site general error: %v", err) |
| 726 | return |
| 727 | } |
| 728 | parsedURL, err := url.Parse(general.SiteUrl) |
| 729 | if err != nil { |
| 730 | log.Errorf("parse url error: %v", err) |
| 731 | return |
| 732 | } |
| 733 | ctx.SetCookie(constant.UserVisitCookiesCacheKey, |
| 734 | visitToken, constant.UserVisitCacheTime, "/", parsedURL.Hostname(), true, true) |
| 735 | } |
no test coverage detected