Swass
Swass

Reputation: 310

Symfony2: Use session object in Twig file

In Symfony2, how to access session object and check whether Session is set or not from a twig file?

Upvotes: 0

Views: 317

Answers (1)

ghostika
ghostika

Reputation: 1503

It's a pretty easy stuff.

You can access the session with this shortcut:

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

Also check for existence:

{{ app.session.has('key') }}

Upvotes: 2

Related Questions