From ad9dfc9c42b6597515d9eb0a96e9f069372dffdd Mon Sep 17 00:00:00 2001 From: =Corey Hulen Date: Thu, 28 Apr 2016 17:03:52 -0700 Subject: Fixing cookie --- api/user.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/api/user.go b/api/user.go index b905fb639..0962b7cbc 100644 --- a/api/user.go +++ b/api/user.go @@ -711,6 +711,11 @@ func Login(c *Context, w http.ResponseWriter, r *http.Request, user *model.User, w.Header().Set(model.HEADER_TOKEN, session.Token) + secure := false + if GetProtocol(r) == "https" { + secure := true + } + expiresAt := time.Unix(model.GetMillis()/1000+int64(maxAge), 0) sessionCookie := &http.Cookie{ Name: model.SESSION_COOKIE_TOKEN, @@ -719,6 +724,7 @@ func Login(c *Context, w http.ResponseWriter, r *http.Request, user *model.User, MaxAge: maxAge, Expires: expiresAt, HttpOnly: true, + Secure: secure, } http.SetCookie(w, sessionCookie) -- cgit v1.2.3-1-g7c22