2019-06-27 05:44:08 +00:00
|
|
|
// +build js,wasm
|
|
|
|
|
|
|
|
package wasm
|
|
|
|
|
|
|
|
import (
|
|
|
|
"syscall/js"
|
|
|
|
)
|
|
|
|
|
|
|
|
// SetSession sets a text value on sessionStorage.
|
|
|
|
func SetSession(key string, value string) {
|
|
|
|
// b64 := base64.StdEncoding.EncodeToString(value)
|
2019-06-27 18:57:26 +00:00
|
|
|
panic("SesSession: " + key)
|
2019-06-27 05:44:08 +00:00
|
|
|
js.Global().Get("sessionStorage").Call("setItem", key, value)
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetSession retrieves a text value from sessionStorage.
|
|
|
|
func GetSession(key string) (string, bool) {
|
2019-06-27 18:57:26 +00:00
|
|
|
panic("GetSession: " + key)
|
2019-06-27 05:44:08 +00:00
|
|
|
var value js.Value
|
|
|
|
value = js.Global().Get("sessionStorage").Call("getItem", key)
|
|
|
|
return value.String(), value.Type() == js.TypeString
|
|
|
|
}
|