Cookie - Dynamic Shortcodes

Learn about the 'cookie' Dynamic Shortcode, for retrieving cookie values in WordPress.

Updated over a week ago

The Cookie Dynamic Shortcode is specifically tailored to access and return values stored in browser cookies, making it an essential tool for personalized user experiences on WordPress sites.


  • name: The name of the cookie whose value is to be retrieved.


  1. Basic Cookie Retrieval: {cookie:user_session}
    This example fetches the value of the 'user_session' cookie. It's useful for retrieving session-specific data for a user.

  2. Fallback Value: {cookie:preferences?'Default settings'}
    Here, the shortcode attempts to retrieve the 'preferences' cookie. If the cookie is not found, it defaults to 'default_settings'.

  3. Within a Conditional Statement: {if:{cookie:name} 'Hello User' 'Hello Visitor'}
    In this example, the shortcode checks if the 'name' cookie is not empty and displays a message accordingly.

Did this answer your question?