Description
This shortcode reads a value from the $_SESSION superglobal and displays it on the page. It is commonly used to access PHP session data for the current visitor, such as login state or session-scoped variables.
Shortcode Examples
Read a session variable named source:
[memb_session name="source"]
Display a session value with a fallback:
[memb_session name="source" default="organic"]
Check whether the visitor is logged in:
[memb_session name="is_logged_in" default="0"]
Apply text formatting to the output:
[memb_session name="source" txtfmt="ucfirst"]
Shortcode Parameters
name | (Required) Comma-delimited list of keys to look up in the $_SESSION 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_session] with no parameters displays all $_SESSION variables for debugging purposes. Session data is only available after a session has been started with session_start() or equivalent. Memberium automatically manages sessions for logged-in members.
Shortcode Attributes
| Conditional | No |
|---|---|
| Nestable | No |
| Accepts formatting | Yes |
| Capturable | Yes |