In case you missed it, session variables are described here viewtopic.php?f=5&t=7377
Also this tip uses multi-value variables described here viewtopic.php?f=5&t=10892
So with 'cms:get_session' tag we can get a certain variable stored in session, if we know this variable's name.
A way to know all variables that are stored in session without need to know their names (code is based on this tip viewtopic.php?f=8&t=11092):
Code creates an array of variable names and values in 'k_session' multi-value variable. Also it adds a flag 'k_session_set' which helps to check if any session variable is set. All these variables can be seen in output of 'cms:dump_all' tag.
Also this tip uses multi-value variables described here viewtopic.php?f=5&t=10892
So with 'cms:get_session' tag we can get a certain variable stored in session, if we know this variable's name.
A way to know all variables that are stored in session without need to know their names (code is based on this tip viewtopic.php?f=8&t=11092):
- Code: Select all
// Create a variable for debug
$FUNCS->add_event_listener( 'add_render_vars', 'add_session_vars' );
function add_session_vars(){
global $CTX;
// Dump session for everyone
if( count($_SESSION) > 1 ){
$CTX->set( 'k_session', array(), 'global', 1 );
$CTX->set( 'k_session_set', 1, 'global', 1 );
foreach( $_SESSION as $k=>$v ){
if( $k != 'KSESSIONmsgs' ){
$CTX->set( 'k_session.' . $k, $v, 'global' ); // k_session.myvar
}
}
}
}
Code creates an array of variable names and values in 'k_session' multi-value variable. Also it adds a flag 'k_session_set' which helps to check if any session variable is set. All these variables can be seen in output of 'cms:dump_all' tag.