Skip to main content

i4w_ifcookie

Usage

This shortcode is designed to check for the existence of a cookie and, given a value to check, for a value match. Any content embedded between the tags will be displayed if the criteria is met.

[ELSE_ifcookie] conditional branching is supported.

Shortcode nesting is supported: [i4w_ifcookie1] thru [i4w_ifcookie19] and [ELSE_ifcookie1] thru [ELSE_ifcookie19]

Parameters

ParameterDescriptionDefaultRequired
cookieThe name of the cookie for whose existence you are checking.NoneYes
valA value which the cookie must hold in order for the shortcode to evaluate to true.NoneNo

Example

Will display "Test Cookie is set" if a cookie by the name of "test_cookie" exists, without checking the value:

Shortcode
[i4w_ifcookie cookie='test_cookie']
Test Cookie is set
[ELSE_ifcookie]
Test Cookie is NOT set
[/i4w_ifcookie]

Will display "Test Cookie is set to 123" if a cookie by the name of "test_cookie" exists AND its value is 123:

Shortcode
[i4w_ifcookie cookie='test_cookie' val=123]
Test Cookie is set to 123
[ELSE_ifcookie]
Test Cookie is NOT set to 123
[/i4w_ifcookie]