-
Notifications
You must be signed in to change notification settings - Fork 0
/
session.go
50 lines (41 loc) · 1.35 KB
/
session.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// -----------------------------------------------------------------------------
// ZR Library - Web Package zr-web/[session.go]
// (c) [email protected] License: MIT
// -----------------------------------------------------------------------------
package web
// (ob *Session) ID() string
// (ob *Session) GetSetting(name string) string
// (ob *Session) SetSetting(name string, value interface{})
import (
"sync"
"github.com/balacode/zr"
)
// Session _ _
type Session struct {
id string
m map[string]string
mutex sync.Mutex
} // Session
// ID _ _
func (ob *Session) ID() string {
var ret string
ob.mutex.Lock()
ret = ob.id
ob.mutex.Unlock()
return ret
} // ID
// GetSetting _ _
func (ob *Session) GetSetting(name string) string {
var ret string
ob.mutex.Lock()
ret = ob.m[name]
ob.mutex.Unlock()
return ret
} // GetSetting
// SetSetting _ _
func (ob *Session) SetSetting(name string, value interface{}) {
ob.mutex.Lock()
ob.m[name] = zr.String(value)
ob.mutex.Unlock()
} // SetSetting
// end