mirror of
https://github.com/astaxie/beego.git
synced 2024-11-22 17:21:02 +00:00
fix #206
This commit is contained in:
parent
a616087cde
commit
a85d91b4bd
6
flash.go
6
flash.go
@ -6,6 +6,8 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const BEEGO_FLASH_SEP = "#BEEGOFLASH#"
|
||||||
|
|
||||||
type FlashData struct {
|
type FlashData struct {
|
||||||
Data map[string]string
|
Data map[string]string
|
||||||
}
|
}
|
||||||
@ -44,7 +46,7 @@ func (fd *FlashData) Store(c *Controller) {
|
|||||||
c.Data["flash"] = fd.Data
|
c.Data["flash"] = fd.Data
|
||||||
var flashValue string
|
var flashValue string
|
||||||
for key, value := range fd.Data {
|
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, "/")
|
c.Ctx.SetCookie("BEEGO_FLASH", url.QueryEscape(flashValue), 0, "/")
|
||||||
}
|
}
|
||||||
@ -58,7 +60,7 @@ func ReadFromRequest(c *Controller) *FlashData {
|
|||||||
vals := strings.Split(v, "\x00")
|
vals := strings.Split(v, "\x00")
|
||||||
for _, v := range vals {
|
for _, v := range vals {
|
||||||
if len(v) > 0 {
|
if len(v) > 0 {
|
||||||
kv := strings.Split(v, ":")
|
kv := strings.Split(v, BEEGO_FLASH_SEP)
|
||||||
if len(kv) == 2 {
|
if len(kv) == 2 {
|
||||||
flash.Data[kv[0]] = kv[1]
|
flash.Data[kv[0]] = kv[1]
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user