Set_client

Set_client

{% set_client %}

Saves custom properties on the client that will survive across multiple sessions until they are changed, unset, or the "session" permission expires. Note that this doesn't mean much unless the user (or the developer) has granted permission for sessions.

{% set_client properties %}

{% set_client
properties
 
Key:value pairs with unique keys. May use the variable arguments syntax.
%}

Related

{% set_title %}

Sets the page title.

{{ client }}

The client object is available on every page, and contains information about the history of the browser used to access the site. Note that most of these properties are only meaningful if the user has allowed permission for sessions. Additionally, client properties require cookies in order to work. Requests made without cookies (such as by bots or browsers with cookies disabled) or without permission for session will always behave like an initial page-load without existing client information. The client 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.

{% set_description %}

Sets the meta description for the current page, which is output by default as part of an HTML page's {{ automatic_markup }}.

{% set_session %}

Saves custom properties on the session. Note that this doesn't mean much unless the user (or the developer) has granted permission for sessions.

{% set_timezone %}

Sets the default timezone to use when rendering dates and times on the page that do not already have a separate timezone configured.

{% set_content_type %}

Sets the Content-Type header for the HTTP response.

{% unset_client %}

Removes custom properties from the client.

{% unset_client_permission %}

Removes the specified permissions from the permissions cookie. Note that this is not the same as denying permission since there will be no record that permission was either granted or denied after the permission has been unset.

{% set_robots %}

Sets the robots meta directive.

{% set_favicon %}

Sets the URL to the favicon for the current page, which is output by default as part of an HTML page's {{ automatic_markup }}.

{% set_profile_setting %}

Saves custom values to predefined profile settings that will be accessible whenever the current profile is logged in. Note that this is meaningless unless the user is logged in. Profile settings may include validation, in which case all settings will be validated before being set and any validation error will prevent the setting(s) from being set. Validation errors may optionally be output to a variable.

{% set %}

Replaces a value on the nearest scope where it has already been defined. If it has not been defined yet, it is stored on the root scope.

{% set_header %}

Sets one or more headers in the HTTP response.

{% set_client_permission %}

Defines whether the client has granted or deined permission for a particular feature (eg: sessions). The only permission defined by default is the session permission (configurable in the site properties). However, the template developer may use this mechanism for their own purposes as well. The permissions defined by this method will be stored in the permissions cookie, which may be read and/or modified by client-side javascript.

{% set_dictionary %}

Sets properties on an editable dictionary object. If the dictionary does not exist it will be created and stored on the current scope. If the dictionary exists but is not editable this will throw an error.

{% set_cookie %}

Sets a cookie in the HTTP response.

{{ client_permissions }}

The client_permissions object is available on every page, and contains information about whether or not the user (or developer) has granted permission to use specific features. By default the only feature controlled by this is sessions, but the permission system may be "extended" arbitrarily by the developer to control additional features. The permissions feature requires cookies in order to work. Requests made without cookies (such as by bots or browsers with cookies disabled) will always behave like an initial page-load without existing permission information.

{% set_canonical_url %}

Sets the canonical URL for the current page, which is output by default as part of an HTML page's {{ automatic_markup }}.

{% set_response_code %}

Sets the HTTP response status code.

{% set_profile %}

Saves custom properties on the profile that will be accessible whenever the current profile is logged in. The properties will be saved to the profile's attribute dictionary. Note that this is meaningless unless the user is logged in.

Examples

How to use the set_client method

Copy

Simple Use Case

{% if request.query_params.hide_popup_for_all_time %}
{% set_client show_popup:"false" %}
{% endif %}
This example uses the set_client method to save the "show_popup" query parameter, so that future visits to the same page will not show the popup.

Multiple Dynamic Values

{% if submission.is_valid %}
{% var forms_submitted = client.submittedForms | to_int | plus: 1 %}
{% var client_formname = form.name.value | prepend: 'submitted' %}
{% set_client submittedForms:forms_submitted lastKnownEmail:submission.email &client_formname:'true' %}
{% endif %}
This example uses the set_client method to save multiple dynamic values on the client for later use. The submittedForms variable is incremented by 1, the lastKnownEmail variable is set to the submission email, and a dynamic variable constructed from the name of the form prepended by 'submitted' will also be set to 'true'.