Whenever a template requests to use #AUTORISER
, #SESSION
or any other tag which requires the creation of a different cache for each session, a special identifier is calculated with the session information known about the visitor by the spip_session
function. This identifier is used to name the cache files. When no information is known about the visitor, the identifier returned is null.
The definir_session
pipeline is used to complete the information used to create this identifier. It is also possible to compose unique caches relying on other parameters rather than data relating to the visitor.
The pipeline receives and returns a character string. It is called as in the file ecrire/inc/utils.php:
$s = pipeline('definir_session',
$GLOBALS['visiteur_session']
? serialize($GLOBALS['visiteur_session'])
. '_' . @$_COOKIE['spip_session']
: ''
);
Remarks: the session data can be required very early on in SPIP’s operations, so it is best to declare the the pipeline function for a plugin directly in the options file. The declaration in the plugin.xml
file does not need to define the XML tag <inclure>
in such circumstances:
<options>prefixPlugin_options.php</options>
<pipeline>
<nom>definir_session</nom>
</pipeline>