path default is /
httponly default true seuce default not set
Showing
1 changed file
with
8 additions
and
4 deletions
| ... | @@ -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()) | ... | ... |
-
Please register or sign in to post a comment