I have array in session, but I can't show them. My code: Controller:
$game = $request->query->get('game');
$type = $request->query->get('type');
$odd = $request->query->get('odd');
$kupon = array(
'game' => $game,
'type' => $type,
'odd' => $odd,
);
$this->get('session')->set('kupon', $kupon);
Where 'game' is for example: 'Arsenal - Chelsea', 'type' is number like 1, and odd is float number like '2.2'.
Twig file:
{% if app.session.get('kupon') is not null %}
<table>
{% for kupon in session %}
<tr>
<td>{{ kupon.game }}</td>
<td>{{ kupon.type }}</td>
<td> </td>
</tr>
{% endfor %}
</table>
And everything ok, but when I try log in and show data session, I have this error:
Impossible to access an attribute ("game") on a string variable ("PNdjNUeuZ_d5uJlm1VG7zPZhp2Vb4CY3nDf93vAQ574") in baw\kupon.html.twig at line 13.
This variable is from session after log in, I checked dump information about it:
array(3) {
["_csrf/login"]=> string(43) "PNdjNUeuZ_d5uJlm1VG7zPZhp2Vb4CY3nDf93vAQ574" ["login"]=> string(4) "test"
["kupon"]=> array(3) { ["game"]=> string(31) "Arsenal Londyn - Chelsea Londyn" ["type"]=> string(1) "1" ["odd"]=> string(3) "2.2" } }
And now I haven't any idea to fix this.