1
0
mirror of https://github.com/astaxie/beego.git synced 2024-12-22 10:40:49 +00:00
This commit is contained in:
astaxie 2013-09-19 23:04:05 +08:00
parent a616087cde
commit a85d91b4bd

View File

@ -6,6 +6,8 @@ import (
"strings"
)
const BEEGO_FLASH_SEP = "#BEEGOFLASH#"
type FlashData struct {
Data map[string]string
}
@ -44,7 +46,7 @@ func (fd *FlashData) Store(c *Controller) {
c.Data["flash"] = fd.Data
var flashValue string
for key, value := range fd.Data {
flashValue += "\x00" + key + ":" + value + "\x00"
flashValue += "\x00" + key + BEEGO_FLASH_SEP + value + "\x00"
}
c.Ctx.SetCookie("BEEGO_FLASH", url.QueryEscape(flashValue), 0, "/")
}
@ -58,7 +60,7 @@ func ReadFromRequest(c *Controller) *FlashData {
vals := strings.Split(v, "\x00")
for _, v := range vals {
if len(v) > 0 {
kv := strings.Split(v, ":")
kv := strings.Split(v, BEEGO_FLASH_SEP)
if len(kv) == 2 {
flash.Data[kv[0]] = kv[1]
}