From 002e0854ab69b7a849fe05484307f14c0fd66040 Mon Sep 17 00:00:00 2001 From: "asta.xie" Date: Sat, 22 Feb 2014 10:37:14 +0800 Subject: [PATCH] path default is / httponly default true seuce default not set --- context/output.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/context/output.go b/context/output.go index 43948e15..303b0e6a 100644 --- a/context/output.go +++ b/context/output.go @@ -99,15 +99,19 @@ func (output *BeegoOutput) Cookie(name string, value string, others ...interface } } if len(others) > 1 { - fmt.Fprintf(&b, "; Path=%s", sanitizeValue(others[1].(string))) + if len(others[1].(string)) == 0 { + fmt.Fprintf(&b, "; Path=%s", '/') + } else { + fmt.Fprintf(&b, "; Path=%s", sanitizeValue(others[1].(string))) + } } - if len(others) > 2 { + if len(others) > 2 && len(others[2].(string)) > 0 { fmt.Fprintf(&b, "; Domain=%s", sanitizeValue(others[2].(string))) } - if len(others) > 3 { + if len(others) > 3 && others[3].(bool) { fmt.Fprintf(&b, "; Secure") } - if len(others) > 4 { + if !(len(others) > 4 && others[4].(bool) == false) { fmt.Fprintf(&b, "; HttpOnly") } output.Context.ResponseWriter.Header().Add("Set-Cookie", b.String())