Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Session Issue

How to use session on a view page phalcon I want to save specific value in new session variable

edited Sep '14

you can access session directly in your view
Just print it out

{{ session.something }}

or something like this

{% if session.userid is 1 %}
    {{ 'is 1' }}
{% else %}
    {{ 'Not 1' }}
{% endif %}


i want to save into session not using volt

edited Sep '14

If you are using volt you are able to use service that you have define in depency container

here is some refence :

If you wan set session within view

{{ session.set("key", "value") }}

if you dont want use vold you could access DI in static way fro your view

$session = Phalcon\DI::getDefault()->getSession(); $session->set("key", "value");


Why do you need to set session value in your view?
It's probably not a good idea

I think you can just do it in your controller.


how to destroy session in a view itself

edited Sep '14

{{ session.destroy() }} or $session->destroy();