示例#1
0
文件: hello.go 项目: arfian/knot
func (w *WorldController) Cookie(r *knot.Request) interface{} {
	r.ResponseConfig().OutputType = knot.OutputHtml
	cvalue := ""
	cookiename := "mycookie"
	c, _ := r.Cookie(cookiename)
	if c == nil {
		r.SetCookie(cookiename, "Arief Darmawan", 30*24*time.Hour)
	} else {
		cvalue = c.Value
		c.Value = "Arief Darmawan" + time.Now().String()
		c.Expires = time.Now().Add(24 * 30 * time.Hour)
	}
	return "Cookie value is " + cvalue
}