bb5351bb by Yongzheng Lai Committed by astaxie

Update output.go

fix cookie not work in IE
1 parent 26130a5d
...@@ -98,23 +98,25 @@ func (output *BeegoOutput) Body(content []byte) { ...@@ -98,23 +98,25 @@ func (output *BeegoOutput) Body(content []byte) {
98 func (output *BeegoOutput) Cookie(name string, value string, others ...interface{}) { 98 func (output *BeegoOutput) Cookie(name string, value string, others ...interface{}) {
99 var b bytes.Buffer 99 var b bytes.Buffer
100 fmt.Fprintf(&b, "%s=%s", sanitizeName(name), sanitizeValue(value)) 100 fmt.Fprintf(&b, "%s=%s", sanitizeName(name), sanitizeValue(value))
101
102 //fix cookie not work in IE
101 if len(others) > 0 { 103 if len(others) > 0 {
102 switch v := others[0].(type) { 104 switch v := others[0].(type) {
103 case int: 105 case int:
104 if v > 0 { 106 if v > 0 {
105 fmt.Fprintf(&b, "; Max-Age=%d", v) 107 fmt.Fprintf(&b, "; Expires=%s; Max-Age=%d", time.Now().Add(time.Duration(v) * time.Second).UTC().Format(time.RFC1123), v)
106 } else if v < 0 { 108 } else if v < 0 {
107 fmt.Fprintf(&b, "; Max-Age=0") 109 fmt.Fprintf(&b, "; Max-Age=0")
108 } 110 }
109 case int64: 111 case int64:
110 if v > 0 { 112 if v > 0 {
111 fmt.Fprintf(&b, "; Max-Age=%d", v) 113 fmt.Fprintf(&b, "; Expires=%s; Max-Age=%d", time.Now().Add(time.Duration(v) * time.Second).UTC().Format(time.RFC1123), v)
112 } else if v < 0 { 114 } else if v < 0 {
113 fmt.Fprintf(&b, "; Max-Age=0") 115 fmt.Fprintf(&b, "; Max-Age=0")
114 } 116 }
115 case int32: 117 case int32:
116 if v > 0 { 118 if v > 0 {
117 fmt.Fprintf(&b, "; Max-Age=%d", v) 119 fmt.Fprintf(&b, "; Expires=%s; Max-Age=%d", time.Now().Add(time.Duration(v) * time.Second).UTC().Format(time.RFC1123), v)
118 } else if v < 0 { 120 } else if v < 0 {
119 fmt.Fprintf(&b, "; Max-Age=0") 121 fmt.Fprintf(&b, "; Max-Age=0")
120 } 122 }
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!