SESSION_KEY="$(update_session)"
SET_COOKIE 0 session="$SESSION_KEY" Path=/ SameSite=Strict HttpOnly
SESSION_ID="${SESSION_KEY%% *}"
+
+SESSION_BIND() {
+ local key="$1" value="$2"
+ SET_COOKIE session "$key"="${value} $(session_mac "$value" "$SESSION_ID")"
+}
+
+SESSION_VAR() {
+ local key="$1"
+ local value sig
+ value="$(COOKIE "$key")"
+ sig="${value##* }" value="${value% *}"
+ if [ "$sig" = "$(session_mac "$value" "$SESSION_ID")" ]; then
+ printf %s\\n "$value"
+ else
+ return 1
+ fi
+}