Click the "Download" button below to retrieve a copy of this tag,
including the complete documentation and sample usage shown
on this page. Place the downloaded ".inc" file in your
LassoStartup folder, restart Lasso, and you can begin using this
tag immediately.
[
define_tag:'lp_session_vars',
-description='Returns all session vars, or if a session name is specified, just the vars for that session name.',
-priority='replace',
-optional='session_name',
-optional='string';
local:'vars' = array;
local:'session' = array;
local:'varnames' = array;
if: local_defined:'session_name';
#session->(insert: '_SessionTracker_' #session_name '_Vars');
else;
// get session name and session ID as an array of pairs
#session = (lp_session_id: -vars);
// get just the name of the session
#session->(foreach: {params->first = params->first->name; Return: True;} );
// now get the variable name that stores the session variable names
#session->(foreach: {params->first->(append:'_Vars'); Return: True;} );
/if;
iterate: #session, local:'i';
if: (var: #i)->type == 'array';
#varnames->(merge: (var: #i));
/if;
/iterate;
if: local_defined:'string';
iterate: #varnames, local:'i';
#vars->(insert: #i + '=' + (var: #i));
/iterate;
return: #vars->(join:', ');
else;
iterate: #varnames, local:'i';
#vars->(insert: #i = (var: #i));
/iterate;
return: #vars;
/if;
/define_tag;
]