1
0
mirror of https://github.com/astaxie/beego.git synced 2024-11-22 18:00:55 +00:00

fix setcookie time type

This commit is contained in:
astaxie 2013-07-11 10:57:34 +08:00
parent af3797e16c
commit 60200689f4

View File

@ -72,7 +72,14 @@ func (ctx *Context) SetCookie(name string, value string, others ...interface{})
var b bytes.Buffer var b bytes.Buffer
fmt.Fprintf(&b, "%s=%s", sanitizeName(name), sanitizeValue(value)) fmt.Fprintf(&b, "%s=%s", sanitizeName(name), sanitizeValue(value))
if len(others) > 0 { if len(others) > 0 {
fmt.Fprintf(&b, "; Max-Age=%d", others[0].(int64)) switch others[0].(type) {
case int:
fmt.Fprintf(&b, "; Max-Age=%d", others[0].(int))
case int64:
fmt.Fprintf(&b, "; Max-Age=%d", others[0].(int64))
case int32:
fmt.Fprintf(&b, "; Max-Age=%d", others[0].(int32))
}
} else { } else {
fmt.Fprintf(&b, "; Max-Age=0") fmt.Fprintf(&b, "; Max-Age=0")
} }