Session Plugin
The session plugin gives you the ability to set and read session data.
session:data
{{ session:data }}
Displays or sets a piece of session data.
If you supply a value, it will set the session data and display nothing, otherwise the existing value of name will be displayed.
Attributes
| Name | Default | Required | Description |
|---|---|---|---|
| name | None | Yes | Name of the data you want to display or set. |
| value | None | No | Add a value to set data instead of displaying it. |
Examples
Setting data:
{{ session:data name="color_preference" value="red" }}
Displaying data:
{{ session:data name="color_preference" }}
Returns:
red
session:flash
Identical to the data function, but uses flash data.
Flash data is data that is only available for the next page load, then it is destroyed.
Examples
Setting data:
{{ session:flash name="color_preference" value="blue" }}
Displaying data:
{{ session:flash name="color_preference" }}
Returns:
blue
session:messages
Displays a flashdata message.
PyroCMS has standardized messages to belong to one of three categories:
- success
- notice
- error
Each has a different meaning and by default will appear with a class name associated to it.
Attributes
| Name | Default | Required | Description |
|---|---|---|---|
| success | success | No | Set your own class name for success messages. |
| notice | notice | No | Set your own class name for notice messages. |
| error | error | No | Set your own class name for error messages. |
Examples
Standard output:
{{ session:messages }}
Returns:
<div class="error">There was an error.</div>
With custom classes:
{{ session:messages success="my_success_class" }}
Returns:
<div class="my_success_class">Success!</div>
