mirror of
https://github.com/astaxie/beego.git
synced 2024-11-22 17:00:55 +00:00
path default is /
httponly default true seuce default not set
This commit is contained in:
parent
b405e19f56
commit
69982c62c8
@ -99,15 +99,19 @@ func (output *BeegoOutput) Cookie(name string, value string, others ...interface
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if len(others) > 1 {
|
if len(others) > 1 {
|
||||||
|
if len(others[1].(string)) == 0 {
|
||||||
|
fmt.Fprintf(&b, "; Path=%s", '/')
|
||||||
|
} else {
|
||||||
fmt.Fprintf(&b, "; Path=%s", sanitizeValue(others[1].(string)))
|
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)))
|
fmt.Fprintf(&b, "; Domain=%s", sanitizeValue(others[2].(string)))
|
||||||
}
|
}
|
||||||
if len(others) > 3 {
|
if len(others) > 3 && others[3].(bool) {
|
||||||
fmt.Fprintf(&b, "; Secure")
|
fmt.Fprintf(&b, "; Secure")
|
||||||
}
|
}
|
||||||
if len(others) > 4 {
|
if !(len(others) > 4 && others[4].(bool) == false) {
|
||||||
fmt.Fprintf(&b, "; HttpOnly")
|
fmt.Fprintf(&b, "; HttpOnly")
|
||||||
}
|
}
|
||||||
output.Context.ResponseWriter.Header().Add("Set-Cookie", b.String())
|
output.Context.ResponseWriter.Header().Add("Set-Cookie", b.String())
|
||||||
|
Loading…
Reference in New Issue
Block a user