Description
This shortcode reads a value from the $_COOKIE superglobal and displays it on the page. It is commonly used to access browser cookie values set by your site or third-party scripts.
Shortcode Examples
Read a cookie named source:
[memb_cookie name="source"]
Display a cookie value with a fallback if it does not exist:
[memb_cookie name="source" default="direct"]
Read the PHP session ID cookie:
[memb_cookie name="PHPSESSID"]
Apply text formatting to the output:
[memb_cookie name="source" txtfmt="strtoupper"]
Shortcode Parameters
name | (Required) Comma-delimited list of keys to look up in the $_COOKIE variable. |
|---|---|
default | The default value to use if the key is empty. Defaults to an empty string. |
txtfmt | (Optional) Comma-delimited list of text processing functions to apply to the output. |
capture | Captures the shortcode output and routes it to a variable for later use. |
before | Text to display before the output value. |
after | Text to display after the output value. |
htmlattr | If set, outputs the value as an HTML attribute rather than as visible text. |
Additional Information
Using [memb_cookie] with no parameters displays all $_COOKIE variables for debugging purposes. Cookie availability depends on the cookie’s path and domain settings—a cookie set for a subdomain or specific path may not be visible on the current page.
Shortcode Attributes
| Conditional | No |
|---|---|
| Nestable | No |
| Accepts formatting | Yes |
| Capturable | Yes |