69982c62 by asta.xie

path default is /

httponly default true
seuce default not set
1 parent b405e19f
...@@ -99,15 +99,19 @@ func (output *BeegoOutput) Cookie(name string, value string, others ...interface ...@@ -99,15 +99,19 @@ func (output *BeegoOutput) Cookie(name string, value string, others ...interface
99 } 99 }
100 } 100 }
101 if len(others) > 1 { 101 if len(others) > 1 {
102 fmt.Fprintf(&b, "; Path=%s", sanitizeValue(others[1].(string))) 102 if len(others[1].(string)) == 0 {
103 fmt.Fprintf(&b, "; Path=%s", '/')
104 } else {
105 fmt.Fprintf(&b, "; Path=%s", sanitizeValue(others[1].(string)))
106 }
103 } 107 }
104 if len(others) > 2 { 108 if len(others) > 2 && len(others[2].(string)) > 0 {
105 fmt.Fprintf(&b, "; Domain=%s", sanitizeValue(others[2].(string))) 109 fmt.Fprintf(&b, "; Domain=%s", sanitizeValue(others[2].(string)))
106 } 110 }
107 if len(others) > 3 { 111 if len(others) > 3 && others[3].(bool) {
108 fmt.Fprintf(&b, "; Secure") 112 fmt.Fprintf(&b, "; Secure")
109 } 113 }
110 if len(others) > 4 { 114 if !(len(others) > 4 && others[4].(bool) == false) {
111 fmt.Fprintf(&b, "; HttpOnly") 115 fmt.Fprintf(&b, "; HttpOnly")
112 } 116 }
113 output.Context.ResponseWriter.Header().Add("Set-Cookie", b.String()) 117 output.Context.ResponseWriter.Header().Add("Set-Cookie", b.String())
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!