enact.session

Access and manipulate current php session data. Calling enact.session returns a \Disco\classes\Session instance, read the Disco documentation on the session class here.

A few basic examples

enact.session.set

Set a variable in the session.

{{ enact.session.set('last-access', 'now'|date('Y-m-d H:m:s')) }}
enact.session.get

Get a variable in the session.

<div>Last access : {{ enact.session.get('last-access') }}</div>
enact.session.has

Whether a variable exists in the session.

{% if enact.session.has('last-access') %}

    //we got it

{% endif %}
enact.session.remove

Remove a variable from the session.

{{ enact.session.remove('last-access') }}
enact.session.setFlash

Set a flashed session variable, flashed data is only good for one subsequent request.

{{ enact.session.setFlash('user-form-error', 'There was an error processing your data') }}
enact.session.getFlash

Get a flashed session variable.

<div>{{ enact.session.getFlash('user-form-error') }}</div>
enact.session.hasFlash

Test if a flash session variable exists.

{% if enact.session.hasFlash('user-form-error') %}

    //have it

{% endif %}