Browse Source

Update sessions.go

Vova Tkach 6 years ago
parent
commit
f3ada5d413
1 changed files with 24 additions and 0 deletions
  1. 24 0
      engine/sessions/sessions.go

+ 24 - 0
engine/sessions/sessions.go

@@ -166,6 +166,30 @@ func (this *Session) GetBool(name string) (bool, error) {
 	}
 }
 
+func (this *Session) GetIntDef(name string, def int) int {
+	if this.IsSetInt(name) {
+		return this.vars.Int[name]
+	} else {
+		return def
+	}
+}
+
+func (this *Session) GetStringDef(name string, def string) string {
+	if this.IsSetString(name) {
+		return this.vars.String[name]
+	} else {
+		return def
+	}
+}
+
+func (this *Session) GetBoolDef(name string, def bool) bool {
+	if this.IsSetBool(name) {
+		return this.vars.Bool[name]
+	} else {
+		return def
+	}
+}
+
 func (this *Session) DelInt(name string) {
 	if this.IsSetInt(name) {
 		delete(this.vars.Int, name)