bb5351bb by Yongzheng Lai Committed by astaxie

Update output.go

fix cookie not work in IE
1 parent 26130a5d
...@@ -98,28 +98,30 @@ func (output *BeegoOutput) Body(content []byte) { ...@@ -98,28 +98,30 @@ 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 if len(others) > 0 { 101
102 switch v := others[0].(type) { 102 //fix cookie not work in IE
103 case int: 103 if len(others) > 0 {
104 if v > 0 { 104 switch v := others[0].(type) {
105 fmt.Fprintf(&b, "; Max-Age=%d", v) 105 case int:
106 } else if v < 0 { 106 if v > 0 {
107 fmt.Fprintf(&b, "; Max-Age=0") 107 fmt.Fprintf(&b, "; Expires=%s; Max-Age=%d", time.Now().Add(time.Duration(v) * time.Second).UTC().Format(time.RFC1123), v)
108 } 108 } else if v < 0 {
109 case int64: 109 fmt.Fprintf(&b, "; Max-Age=0")
110 if v > 0 { 110 }
111 fmt.Fprintf(&b, "; Max-Age=%d", v) 111 case int64:
112 } else if v < 0 { 112 if v > 0 {
113 fmt.Fprintf(&b, "; Max-Age=0") 113 fmt.Fprintf(&b, "; Expires=%s; Max-Age=%d", time.Now().Add(time.Duration(v) * time.Second).UTC().Format(time.RFC1123), v)
114 } 114 } else if v < 0 {
115 case int32: 115 fmt.Fprintf(&b, "; Max-Age=0")
116 if v > 0 { 116 }
117 fmt.Fprintf(&b, "; Max-Age=%d", v) 117 case int32:
118 } else if v < 0 { 118 if v > 0 {
119 fmt.Fprintf(&b, "; Max-Age=0") 119 fmt.Fprintf(&b, "; Expires=%s; Max-Age=%d", time.Now().Add(time.Duration(v) * time.Second).UTC().Format(time.RFC1123), v)
120 } 120 } else if v < 0 {
121 } 121 fmt.Fprintf(&b, "; Max-Age=0")
122 } 122 }
123 }
124 }
123 125
124 // the settings below 126 // the settings below
125 // Path, Domain, Secure, HttpOnly 127 // Path, Domain, Secure, HttpOnly
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!