Free-Conversant Support / Cookie Conditional: cookie.[name].length
 Home   About Conversant   Free Sites   Hosting   Support   XML-RPC 

Search



Documentation >> Conditionals >> Cookies >> cookie.[name].length

Cookie Conditional Macro: cookie.[name].length

Operators:

  • == (equal to)
  • != (not equal to)
  • greaterThan
  • greaterThanOrEqualTo
  • lessThan
  • lessThanOrEqualTo

Usage Notes

  • You *should* make sure that the cookie exists before testing its length, using cookie.[name].exists
  • Tests the length of the current value of a cookie present in the HTTP request.
  • Substitute the actual name of a cookie for the [name] (no brackets) portion of the macro.

Examples

This example will show the first line if the cookie exists and is four characters long, the second line if it exists but it some other length, and the third line if the cookie has not been set.

<!--#if condition="cookie.wysiwygEditor.exists && ( cookie.wysiwygEditor.length == '4' )"-->

1. The wysiwygEditor cookie can only be 'true' or 'false'. It is 4 characters long, so it must be 'true'.

<!--#elseif condition="cookie.wysiwygEditor.exists"-->

2. The wysiwygEditor cookie exists, and it's length is not four, so it must be five, meaning you've set it to 'false'.

<!--#else-->

3. The wysiwygEditor cookie has not been set.

<!--#endif-->

Here is the above code in action:

3. The wysiwygEditor cookie has not been set.

Note that the above example might be easier to read using nested conditionals, like this:

<!--#if condition="cookie.wysiwygEditor.exists"-->

<!--#if condition="cookie.wysiwygEditor.length == '4'"-->

1. The wysiwygEditor cookie can only be 'true' or 'false'. It is 4 characters long, so it must be 'true'.

<!--#else-->

2. The wysiwygEditor cookie exists, and it's length is not four, so it must be five, meaning you've set it to 'false'.

<!--#endif-->

<!--#else-->

3. The wysiwygEditor cookie has not been set.

<!--#endif-->

View in DG