|
@@ -2,6 +2,8 @@ package session
|
|
|
|
|
|
// IsSetString to check if variable exists
|
|
|
func (s *Session) IsSetString(name string) bool {
|
|
|
+ s.varlist.RLock()
|
|
|
+ defer s.varlist.RUnlock()
|
|
|
if _, ok := s.varlist.String[name]; ok {
|
|
|
return true
|
|
|
} else {
|
|
@@ -11,6 +13,8 @@ func (s *Session) IsSetString(name string) bool {
|
|
|
|
|
|
// GetString returns stored variable value or default
|
|
|
func (s *Session) GetString(name string, def string) string {
|
|
|
+ s.varlist.RLock()
|
|
|
+ defer s.varlist.RUnlock()
|
|
|
if v, ok := s.varlist.String[name]; ok {
|
|
|
return v
|
|
|
} else {
|
|
@@ -21,6 +25,8 @@ func (s *Session) GetString(name string, def string) string {
|
|
|
// SetString to set variable value
|
|
|
func (s *Session) SetString(name string, value string) {
|
|
|
isset := s.IsSetString(name)
|
|
|
+ s.varlist.Lock()
|
|
|
+ defer s.varlist.Unlock()
|
|
|
s.varlist.String[name] = value
|
|
|
if isset || value != "" {
|
|
|
s.changed = true
|
|
@@ -30,6 +36,8 @@ func (s *Session) SetString(name string, value string) {
|
|
|
// DelString to remove variable
|
|
|
func (s *Session) DelString(name string) {
|
|
|
if s.IsSetString(name) {
|
|
|
+ s.varlist.Lock()
|
|
|
+ defer s.varlist.Unlock()
|
|
|
delete(s.varlist.String, name)
|
|
|
s.changed = true
|
|
|
}
|