The session object is available on every page, and contains information about the user's current session. Note that most of these properties are only meaningful if the user has allowed permission for sessions.
Additionally, sessions require cookies in order to work. Requests made without cookies (such as by bots or browsers with cookies disabled) or without permission for sessions will always behave like an initial page-load without existing session information.
The session object is one of a handful of simple mechanisms to enable personalization on your site. Used well, these can be powerful tools for developers and website owners.
| Name | Type | Description |
| is_valid | Boolean | Whether or not the user (or template developer) has granted permission for a session |
| allowed | Boolean | Whether or not the user (or template developer) has granted permission for a session |
| id | String | The unique identifier for the user's session. This will contain a value even if the user is not allowed to have a session, but the value will change on every page load |
| first_page | Boolean | True if this is the first page load in the user's current session. Note that this will always return true if the user does not have permission for a session since we will have no "memory" of prior page loads for the current session |
| start_date | time | The time that the current session started (equivalent to the time that the first request was made for this session) |
| end_date | time | The time that the current session will expire if no more requests are made. Note that sessions are extended by every request and so the end_date will also be different on every request |
| num_requests | Integer | The total number of requests for the current session, including requests resulting in errors |
| num_pages | Integer | The total number of successful page requests for the current session. This is different than num_requests in that it does not include any requests which resulted in an HTTP response code other than 200. This also assumes that the current request will return a 200 response code |
| unique_pages | Integer | The total number of unique pages requested in the current session. This number could be significantly lower than num_pages if the user requests several pages multiple times |
| num_errors | Integer | The total number of errors returned in the current session. This includes any request that returns something other than a 200 response code |
| properties | list | The full list of custom properties that have been set for the current session. Note that this list only includes the keys, the values will have to be retrieved using the keys |
| history | list | A list containing the last 100 page views as page_view objects for the current session |
| * | String | Individual custom properties for the session may be accessed using {{ session.propertyName }} or {{ session['property-name'] }} syntax |
| output | String | JSON representation of the session object, similar to calling {{ session | inspect: 3, false }} |
The session object is copyable, and when copied using the {% copy_to_dictionary %} method the keys will be the custom session property names and the values will be the corresponding custom property values.
You may also treat this object as a list containing all of the property names which may be iterated using a {% for %} loop.
Saves custom properties on the session. Note that this doesn't mean much unless the user (or the developer) has granted permission for sessions.
Removes custom properties from the session.
Unset multiple Session properties
CopyUnset Session Properties dynamically
CopySet Session advanced
CopyUnset Session
CopySet Session
CopyList all custom properties for the current session
CopyFirst client Session
CopyThis is your first session {% if session.first_page %}AND your first page!{% endif %}
{% endif %}Logout clear session
CopySession first page
CopyThis is your first pageload this session!
{% endif %}Session Errors
CopyWe appear to be having trouble meeting your needs. Please contact us directly so that we can assist you and fix the trouble for future visitors, or continue browsing for what you need.
{% endif %}