From a420cdf0497b1471fb619e287598f37d3b698530 Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Tue, 2 Sep 2014 09:56:36 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=9A=E8=AF=9D=E9=BB=98=E8=AE=A4=201=20?= =?UTF-8?q?=E5=A4=A9=E8=BF=87=E6=9C=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 691f4ee..e5fd412 100644 --- a/main.go +++ b/main.go @@ -21,12 +21,15 @@ func indexHandler(w http.ResponseWriter, r *http.Request) { session, _ := user.Session.Get(r, "wide-session") if session.IsNew { - // TODO: 以 admin 作为用户登录 + // TODO: 写死以 admin 作为用户登录 name := conf.Wide.Users[0].Name - glog.Infof("[%s] logged in", name) session.Values["username"] = name session.Values["id"] = strconv.Itoa(rand.Int()) + // 一天过期 + session.Options.MaxAge = 60 * 60 * 24 + + glog.Infof("Created a session [%s] for user [%s]", session.Values["id"].(string), name) } session.Save(r, w)