CookiesAction

The CookiesAction allows the sitemap access to the various cookie variables in the current transaction. The component is defined as follows

<map:actions> <map:action name="cookies" src="resource://lib/acting/CookiesAction"/> </map:actions>

It is best to show an example of CookiesAction to see how it is used in the pipeline. If there is a section of the pipeline that requires access to the cookie variables then it is enclosed within the action. For example, from an experimental Paloose CMS site:

<map:pipelines> <map:component-configurations> <map:global-variables> <themesDir>context://themes</themesDir> <defaultTheme>{ant:default-theme}</defaultTheme> <currentTheme>{cookies:theme}</currentTheme> <rootDir>context://</rootDir> </map:global-variables> </map:component-configurations> <map:pipeline> <map:match pattern="/(page).html/" type="regexp"> <map:act type="cookies"> <map:select type="regexp-selector"> <map:parameter name="test-value" value="{global:currentTheme}"/> <map:when test="/.+/"> <map:generate src="context://themes/{global:currentTheme}/data/body.xml" label="raw-xml"/> </map:when> <map:otherwise> <map:generate src="context://themes/astral/data/body.xml" label="raw-xml"/> </map:otherwise> </map:select> <map:transform src="context://system/resources/transforms/buildBody.xsl" label="buildBody-transform"> <map:parameter name="page" value="{1}"/> <map:parameter name="themesDir" value="{global:themesDir}"/> <map:parameter name="theme" value="{global:currentTheme}"/> <map:parameter name="defaultTheme" value="{global:defaultTheme}"/> <map:parameter name="rootDir" value="{global:rootDir}"/> <map:parameter name="queryString" value="{global:query-string}"/> </map:transform> <map:transform src="context://system/resources/transforms/buildPanels.xsl" label="buildPanels-transform"/> <map:transform src="context://site/resources/transforms/buildSite.xsl" label="buildSite-transform"/> <map:transform src="context://themes/{global:currentTheme}/resources/transforms/buildTheme.xsl" label="buildTheme-transform"/> <map:transform src="context://system/resources/transforms/normaliseProperties.xsl" label="normalise-transform"/> <map:transform src="context://system/resources/transforms/page2xhtml.xsl" label="page-transform"/> <map:transform type="moduleWrite"/> <map:serialize type="xhtml"/> </map:act> </map:match>

Note the moduleWrite transformer at the end of the action will updates the cookie variables, in this case the current theme. As the action is terminated (after the serialization the cookies are updated from the cookies module (which is why there is a ModuleWriteTransformer).

Copyright 2006 – 2017 Hugh Field-Richards. All Rights Reserved.