CookiePolicy provides a method to handle the acceptance of cookie policies within your web application.
The basic configuration for accepting cookie policies. The choice is stored in a real cookie (pe:saveCookiePolicy, retention 10 seconds here). While it is valid the panel stays hidden; afterwards it shows again on reload.
<div class="card">
<h5>Basic usage</h5>
<p>The basic configuration for accepting cookie policies. The choice is stored in a real cookie (<code>pe:saveCookiePolicy</code>, retention 10 seconds here). While it is valid the panel stays hidden; afterwards it shows again on reload.</p>
<h:form id="formBasic">
<pe:cookiePolicy id="cookiePolicy">
<p:panel header="PrimeFaces Extensions Cookie Policy">
Do you agree with our cookie policy for about 10 seconds?
<h:panelGrid columns="2">
<p:commandButton value="Only essential cookies" update="cookiePolicy">
<pe:saveCookiePolicy policy="essential" retention="#{10}"/>
</p:commandButton>
<p:commandButton value="Accept all cookies" update="cookiePolicy">
<pe:saveCookiePolicy policy="essential,statistics" retention="#{10}"/>
</p:commandButton>
</h:panelGrid>
</p:panel>
</pe:cookiePolicy>
</h:form>
</div>