Add scope="session" to <set>; replace setenv with it

<set name="x" value="..." scope="session"> now writes x to the session
file (any name, no @ prefix); values are still read with $[@x].
storeVariable passes the scope through instead of repeating the
global/local/parent checks for each value source.

Convert every <setenv> use on barant-site and qualityiron-site to a
plain <set> plus a scope="session" <set>, which keeps same-request
$[name] reads working, and remove setenv from both SESSIONCTL.tag
copies (sessionctl is deprecated for session management).

Document session variables and the set tag scopes in the Jet manual.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Brad ArantandClaude Opus 5.5 committed 2026-11-20 01:46:36 +00:00
1 parent 867ace3cb3
commit 08462ca996
26 files changed
+108 -82

No files matched your search

+23 -31
View File
@@ -1254,6 +1254,17 @@ namespace jet {
(*global.sessionFile)[sessionName] = value; (*global.sessionFile)[sessionName] = value;
return; return;
} }
if(coreutils::MString(scope).toLower() == "session") {
// <set name="x" scope="session"> - the supported way to write a
// session variable (sessionctl's <setenv> and the "@name" prefix
// above are deprecated). Any name, no '@'. Copied into its own
// MString for the same JString::locate() reason as above.
coreutils::MString sessionName(variable);
if(global.sessionFile == NULL)
throw coreutils::Exception("scope=\"session\" requested but no session is active (missing sessiondir keyword, or cgi mode is off).");
(*global.sessionFile)[sessionName] = value;
return;
}
if((scope == "global") || (scope == "")) if((scope == "global") || (scope == ""))
global.variables[variable] = value; global.variables[variable] = value;
else if(scope == "local") { else if(scope == "local") {
@@ -1309,38 +1320,19 @@ namespace jet {
} }
void Tag::storeVariable(coreutils::ZString variable) { void Tag::storeVariable(coreutils::ZString variable) {
if(keywordDefined("expr")) { coreutils::MString scope("global");
if(!keywordDefined("scope") || (resolveKeyword("scope").toLower() == "global")) if(keywordDefined("scope"))
assignVariable(variable, Operand(keywords["expr"], *this).string, "global"); scope = resolveKeyword("scope").toLower();
else if(resolveKeyword("scope").toLower() == "local") if(keywordDefined("expr"))
assignVariable(variable, Operand(keywords["expr"], *this).string, "local"); assignVariable(variable, Operand(keywords["expr"], *this).string, scope);
else if(resolveKeyword("scope").toLower() == "parent") else if(hasContainer) {
assignVariable(variable, Operand(keywords["expr"], *this).string, "parent");
} else if(hasContainer) {
processContainer(container); processContainer(container);
if(evaluate) { if(evaluate)
if(!keywordDefined("scope") || (resolveKeyword("scope").toLower() == "global")) assignVariable(variable, out, scope);
assignVariable(variable, out, "global"); else
else if(resolveKeyword("scope").toLower() == "local") assignVariable(variable, container, scope);
assignVariable(variable, out, "local"); } else
else if(resolveKeyword("scope").toLower() == "parent") assignVariable(variable, resolveKeyword("value"), scope);
assignVariable(variable, out, "parent");
} else {
if(!keywordDefined("scope") || (resolveKeyword("scope").toLower() == "global"))
assignVariable(variable, container, "global");
else if(resolveKeyword("scope").toLower() == "local")
assignVariable(variable, container, "local");
else if(resolveKeyword("scope").toLower() == "parent")
assignVariable(variable, container, "parent");
}
} else {
if(!keywordDefined("scope") || (resolveKeyword("scope").toLower() == "global"))
assignVariable(variable, resolveKeyword("value"), "global");
else if(resolveKeyword("scope").toLower() == "local")
assignVariable(variable, resolveKeyword("value"), "local");
else if(resolveKeyword("scope").toLower() == "parent")
assignVariable(variable, resolveKeyword("value"), "parent");
}
} }
coreutils::MString Tag::processModifier(coreutils::MString &value, coreutils::MString &modifier) { coreutils::MString Tag::processModifier(coreutils::MString &value, coreutils::MString &modifier) {
BIN
View File
Binary file not shown.
+51 -5
View File
@@ -95,9 +95,12 @@ specifying the scope of global.
\item Keyword - within a tag's container we may access the keyword \item Keyword - within a tag's container we may access the keyword
values specified on the containing tag. values specified on the containing tag.
\item Environment - \item Session - values stored in the session file with the set tag and
a scope of session. They persist across requests from the same browser.
\item CGI Variables - \item Environment -
\item CGI Variables -
\end{itemize} \end{itemize}
@@ -120,6 +123,32 @@ the container where they are defined. Some containers may not be
capable of storing local variables (i.e. set tag) and are inheriting capable of storing local variables (i.e. set tag) and are inheriting
the local scope from their parent tag. the local scope from their parent tag.
\section{Session Variables}
Session variables are stored in the session file for the current
session and remain available to later requests from the same browser.
Session control must be enabled (see Session Control).
A session variable is written with the set tag and a scope of
session:
\begin{verbatim}
<set name="_login_id" value="$[login_id]" scope="session">
\end{verbatim}
The name can be any variable name. It does not need an @ prefix.
Session variables are read with the \$[@name] syntax, for example
\$[@\_login\_id].
Setting a session variable does not also set a global variable of
the same name. When the same request needs to read the value as
\$[name], set it with both scopes:
\begin{verbatim}
<set name="_login_id" value="$[login_id]">
<set name="_login_id" value="$[login_id]" scope="session">
\end{verbatim}
\section{Keyword Variables} \section{Keyword Variables}
Keyword variables are set when they are specified on a containing tag. Keyword variables are set when they are specified on a containing tag.
@@ -299,8 +328,16 @@ into the directory named after the token. Captured session data will
become available to future requests coming into the server and made become available to future requests coming into the server and made
available through the variable formats for the session. available through the variable formats for the session.
The <set> tag will also have an additional scope value that can be Under APIServer, session control is enabled for a site by its
used to store the value in the session. This is scope="session". sessionDir setting in the server configuration instead of the <jet>
tag.
Use the <set> tag with scope="session" to store a value in the
session, and \$[@name] to read it back (see Session Variables).
The session tags in SESSIONCTL.tag are deprecated for session
management. Its setenv tag has been removed, and the startsession and
endsession tags are no longer provided. Use scope="session" instead.
@@ -488,7 +525,16 @@ value
container container
scope scope - where the variable is stored. The values are:
\begin{itemize}
\item global - the default. Available to all logic for the rest of the
request.
\item local - available only within the container where it is set.
\item parent - stored in the scope of the enclosing tag.
\item session - stored in the session file and kept across requests.
Requires session control. See Session Variables.
\end{itemize}
\section{sql} \section{sql}
-6
View File
@@ -113,12 +113,6 @@
document.forms[0].requestSubmit();">&nbsp;<CONTAINER>&nbsp;</BUTTON> document.forms[0].requestSubmit();">&nbsp;<CONTAINER>&nbsp;</BUTTON>
</TAG> </TAG>
<tag name="setenv" keywords="name">
<eval name="_envvalue" scope="local"><container></eval>
<set name="#[name]" value="#[_envvalue]">
<set name="@#[name]" value="#[_envvalue]">
</tag>
<tag name="clearenv" keywords="name"> <tag name="clearenv" keywords="name">
<set name="#[name]" value=""> <set name="#[name]" value="">
<set name="@#[name]" value=""> <set name="@#[name]" value="">
+1 -1
View File
@@ -1,7 +1,7 @@
<page> <page>
<title>CRYSTAL</title> <title>CRYSTAL</title>
<contents> <contents>
<setenv name="_menubar"></setenv> <set name="_menubar" value=""><set name="_menubar" value="" scope="session">
<sectionframe title="Crystal - High Security Communications"> <sectionframe title="Crystal - High Security Communications">
<p>Coming soon. High security communications apps for iPhone and <p>Coming soon. High security communications apps for iPhone and
+5 -5
View File
@@ -8,11 +8,11 @@
<set name="login_email" value="$[login_email]"> <set name="login_email" value="$[login_email]">
<set name="login_type" value="$[.type]"> <set name="login_type" value="$[.type]">
<set name="login_uuid" value="$[.uuid]"> <set name="login_uuid" value="$[.uuid]">
<setenv name="_login_id">$[login_id]</setenv> <set name="_login_id" value="$[login_id]"><set name="_login_id" value="$[login_id]" scope="session">
<setenv name="_login_name">$[login_name]</setenv> <set name="_login_name" value="$[login_name]"><set name="_login_name" value="$[login_name]" scope="session">
<setenv name="_login_email">$[login_email]</setenv> <set name="_login_email" value="$[login_email]"><set name="_login_email" value="$[login_email]" scope="session">
<setenv name="_login_type">$[login_type]</setenv> <set name="_login_type" value="$[login_type]"><set name="_login_type" value="$[login_type]" scope="session">
<setenv name="_login_uuid">$[login_uuid]</setenv> <set name="_login_uuid" value="$[login_uuid]"><set name="_login_uuid" value="$[login_uuid]" scope="session">
<sql>update users set last_login=now() where id=$[login_id]</sql> <sql>update users set last_login=now() where id=$[login_id]</sql>
<sql>select group_concat(to_base64(host),':',to_base64(email),':',to_base64(password) order by id separator ';') as accounts_list, <sql>select group_concat(to_base64(host),':',to_base64(email),':',to_base64(password) order by id separator ';') as accounts_list,
(select host from email_accounts where user_id=$[login_id] order by id limit 1) as first_host, (select host from email_accounts where user_id=$[login_id] order by id limit 1) as first_host,
+1 -1
View File
@@ -1,7 +1,7 @@
<page> <page>
<title>LOGIN</title> <title>LOGIN</title>
<contents> <contents>
<setenv name="start">$[start:0]</setenv> <set name="start" value="$[start:0]"><set name="start" value="$[start:0]" scope="session">
<sectionframe title="LOGIN"> <sectionframe title="LOGIN">
<p>Please enter your information below to login.</p> <p>Please enter your information below to login.</p>
+1 -1
View File
@@ -1,7 +1,7 @@
<page> <page>
<title>BARANT Technology Group</title> <title>BARANT Technology Group</title>
<contents> <contents>
<setenv name="_menubar"></setenv> <set name="_menubar" value=""><set name="_menubar" value="" scope="session">
<div id="main-subpage"> <div id="main-subpage">
<if value1="$[SUBPAGE]" value2="" type="eq"> <if value1="$[SUBPAGE]" value2="" type="eq">
<include file="main-overview.subpage"> <include file="main-overview.subpage">
+1 -1
View File
@@ -52,7 +52,7 @@ Payment already processed.
</sql> </sql>
<sql>select last_insert_id() as invoice_id</sql> <sql>select last_insert_id() as invoice_id</sql>
<set name="invoice_id" value="$[.invoice_id]"> <set name="invoice_id" value="$[.invoice_id]">
<setenv name="_invoice_id">$[invoice_id]</setenv> <set name="_invoice_id" value="$[invoice_id]"><set name="_invoice_id" value="$[invoice_id]" scope="session">
<call pgm="/usr/bin/jq" arg1="-j" arg2=".payment.status" input="$[payment]" name="card_charged"> <call pgm="/usr/bin/jq" arg1="-j" arg2=".payment.status" input="$[payment]" name="card_charged">
<call pgm="/usr/bin/jq" arg1="-j" arg2=".payment.card_details.card.card_brand" input="$[payment]" name="card_brand"> <call pgm="/usr/bin/jq" arg1="-j" arg2=".payment.card_details.card.card_brand" input="$[payment]" name="card_brand">
<call pgm="/usr/bin/jq" arg1="-j" arg2=".payment.card_details.card.last_4" input="$[payment]" name="last_4_digits"> <call pgm="/usr/bin/jq" arg1="-j" arg2=".payment.card_details.card.last_4" input="$[payment]" name="last_4_digits">
+1 -1
View File
@@ -16,7 +16,7 @@
audio.play(); audio.play();
} }
</script> </script>
<setenv name="_menubar"></setenv> <set name="_menubar" value=""><set name="_menubar" value="" scope="session">
<sectionframe title="Modular1 Patches"> <sectionframe title="Modular1 Patches">
<div style="width: 48%;"> <div style="width: 48%;">
+1 -1
View File
@@ -3,7 +3,7 @@
<title>PROJECT MANAGER</title> <title>PROJECT MANAGER</title>
<contents> <contents>
<retain name="project_id"> <retain name="project_id">
<setenv name="_menubar">projman.bar</setenv> <set name="_menubar" value="projman.bar"><set name="_menubar" value="projman.bar" scope="session">
<sectionframe title="Project Manager"> <sectionframe title="Project Manager">
<p>An advanced project management methodology not unlike Agile but <p>An advanced project management methodology not unlike Agile but
with a better definition towards software development and the release with a better definition towards software development and the release
+1 -1
View File
@@ -1,3 +1,3 @@
<process> <process>
<setenv name="_product_sku">$[sku]</setenv> <set name="_product_sku" value="$[sku]"><set name="_product_sku" value="$[sku]" scope="session">
</process> </process>
+3 -3
View File
@@ -6,7 +6,7 @@
join users on projects.owner_id=users.id join users on projects.owner_id=users.id
where projects.id=$[project_id] where projects.id=$[project_id]
</sql>$[sqlerror] </sql>$[sqlerror]
<setenv name="_project_id">$[project_id]</setenv> <set name="_project_id" value="$[project_id]"><set name="_project_id" value="$[project_id]" scope="session">
<setenv name="_project_title">$[projman.text]</setenv> <set name="_project_title" value="$[projman.text]"><set name="_project_title" value="$[projman.text]" scope="session">
<setenv name="_menubar">projman.bar</setenv> <set name="_menubar" value="projman.bar"><set name="_menubar" value="projman.bar" scope="session">
</process> </process>
+1 -1
View File
@@ -1,3 +1,3 @@
<process> <process>
<setenv name="_request_id">$[request_id]</setenv> <set name="_request_id" value="$[request_id]"><set name="_request_id" value="$[request_id]" scope="session">
</process> </process>
+4 -4
View File
@@ -9,8 +9,8 @@
join projects on requests.project_id=projects.id join projects on requests.project_id=projects.id
where tasks.id=$[task_id] where tasks.id=$[task_id]
</sql> </sql>
<setenv name="_task_id">$[task_id]</setenv> <set name="_task_id" value="$[task_id]"><set name="_task_id" value="$[task_id]" scope="session">
<setenv name="_request_id">$[projman.request_id]</setenv> <set name="_request_id" value="$[projman.request_id]"><set name="_request_id" value="$[projman.request_id]" scope="session">
<setenv name="_project_id">$[projman.project_id]</setenv> <set name="_project_id" value="$[projman.project_id]"><set name="_project_id" value="$[projman.project_id]" scope="session">
<setenv name="_project_title">$[projman.title]</setenv> <set name="_project_title" value="$[projman.title]"><set name="_project_title" value="$[projman.title]" scope="session">
</process> </process>
+1 -1
View File
@@ -1,7 +1,7 @@
<page> <page>
<title>BARANT Technology Group</title> <title>BARANT Technology Group</title>
<contents> <contents>
<setenv name="_menubar"></setenv> <set name="_menubar" value=""><set name="_menubar" value="" scope="session">
<div id="services-subpage"> <div id="services-subpage">
<if value1="$[SUBPAGE]" value2="" type="eq"> <if value1="$[SUBPAGE]" value2="" type="eq">
<include file="services-overview.subpage"> <include file="services-overview.subpage">
+1 -1
View File
@@ -1 +1 @@
<setenv name="_player_state">$[state]</setenv> <set name="_player_state" value="$[state]"><set name="_player_state" value="$[state]" scope="session">
+1 -1
View File
@@ -1 +1 @@
<setenv name="_player_volume">$[volume]</setenv> <set name="_player_volume" value="$[volume]"><set name="_player_volume" value="$[volume]" scope="session">
+1 -1
View File
@@ -1,7 +1,7 @@
<page> <page>
<title>Wordpress Plugins</title> <title>Wordpress Plugins</title>
<contents> <contents>
<setenv name="_menubar"></setenv> <set name="_menubar" value=""><set name="_menubar" value="" scope="session">
<sectionframe title="BARANT Shopping Cart for WordPress"> <sectionframe title="BARANT Shopping Cart for WordPress">
<div style="display: table; width: 100%;"> <div style="display: table; width: 100%;">
-6
View File
@@ -113,12 +113,6 @@
document.forms[0].requestSubmit();">&nbsp;<CONTAINER>&nbsp;</BUTTON> document.forms[0].requestSubmit();">&nbsp;<CONTAINER>&nbsp;</BUTTON>
</TAG> </TAG>
<tag name="setenv" keywords="name">
<eval name="_envvalue" scope="local"><container></eval>
<set name="#[name]" value="#[_envvalue]">
<set name="@#[name]" value="#[_envvalue]">
</tag>
<tag name="clearenv" keywords="name"> <tag name="clearenv" keywords="name">
<set name="#[name]" value=""> <set name="#[name]" value="">
<set name="@#[name]" value=""> <set name="@#[name]" value="">
+3 -3
View File
@@ -6,9 +6,9 @@
<if value1="$[_session_id]" value2="" type="eq"> <if value1="$[_session_id]" value2="" type="eq">
<createsession> <createsession>
</if> </if>
<setenv name="_login_id">$[_login_id]</setenv> <set name="_login_id" value="$[_login_id]"><set name="_login_id" value="$[_login_id]" scope="session">
<setenv name="_login_name">$[_login_name]</setenv> <set name="_login_name" value="$[_login_name]"><set name="_login_name" value="$[_login_name]" scope="session">
<setenv name="_login_email">$[_login_email]</setenv> <set name="_login_email" value="$[_login_email]"><set name="_login_email" value="$[_login_email]" scope="session">
<sql>update users set last_login=now() where id=$[_login_id]</sql> <sql>update users set last_login=now() where id=$[_login_id]</sql>
<setpage name="home"> <setpage name="home">
</ifrow> </ifrow>
+3 -3
View File
@@ -1,6 +1,6 @@
<process> <process>
<setenv name="_login_id"></setenv> <set name="_login_id" value=""><set name="_login_id" value="" scope="session">
<setenv name="_login_email"></setenv> <set name="_login_email" value=""><set name="_login_email" value="" scope="session">
<setenv name="_login_name"></setenv> <set name="_login_name" value=""><set name="_login_name" value="" scope="session">
<setpage name="login"> <setpage name="login">
</process> </process>
@@ -1,3 +1,3 @@
<process> <process>
<setenv name="_selected_contractor_id">$[selected_contractor_id]</setenv> <set name="_selected_contractor_id" value="$[selected_contractor_id]"><set name="_selected_contractor_id" value="$[selected_contractor_id]" scope="session">
</process> </process>
@@ -1,3 +1,3 @@
<process> <process>
<setenv name="_selected_customer_id">$[selected_customer_id]</setenv> <set name="_selected_customer_id" value="$[selected_customer_id]"><set name="_selected_customer_id" value="$[selected_customer_id]" scope="session">
</process> </process>
+1 -1
View File
@@ -1,3 +1,3 @@
<process> <process>
<setenv name="_selected_job_id">$[selected_job_id]</setenv> <set name="_selected_job_id" value="$[selected_job_id]"><set name="_selected_job_id" value="$[selected_job_id]" scope="session">
</process> </process>
+1 -1
View File
@@ -1,3 +1,3 @@
<process> <process>
<setenv name="_selected_user_id">$[selected_user_id]</setenv> <set name="_selected_user_id" value="$[selected_user_id]"><set name="_selected_user_id" value="$[selected_user_id]" scope="session">
</process> </process>