2

Using print_r($session)) I can see my session data like this:

(
    [code] => 123
    [profile] => 'Admin'
    [data] => Array
        (
            [0] => stdClass Object
                (
                    [Info] => 555
                )
        )
)

Ok, so if I want to print in screen via twig the profile, this works

{{ app.session.get('profile') }}

And I get Admin which is correct. But how can I read the Info ? I thought that something like

{{ app.session.get('data[0].Info') }}

would work but I'm getting blank data. If I use {{ dump(data[0].Info) }} shows the correct info (555).

2
  • try that {{ dump(data.0.Info) }} Commented Nov 26, 2018 at 22:04
  • Works too but I don't need to use dump, how can I use it with app.session.get() ? Commented Nov 26, 2018 at 22:09

1 Answer 1

3

You have to do it step-by-step. First pull the correct variable, afterwards treat it like an array:

{{ app.session.get('data')[0].Info }}
Sign up to request clarification or add additional context in comments.

1 Comment

Yeah, I figured it out later. Thanks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.