ix4n33
ix4n33

Reputation: 586

Is it possible to access session value in Leaf?

Is it possible to get session value in Leaf?

As this post suggested, I should be able to access session using #(request.session).

But when I set a value in session:

try request.assertSession().data.set("foo", "bar")

I got nothing using:

#(request.session.foo)

I also tried:

#(foo)
#(session.foo)
#(session.data.foo)
#(request.session.data.foo)

None of them works.

What am I missing? I'm on Vapor 2.4.4 with Leaf Provider 1.1.0.

Upvotes: 1

Views: 175

Answers (1)

0xTim
0xTim

Reputation: 5620

It is possible to access it - if you pass it in to your context. However, why do you need to access it? I’m not going to say it’s a bad idea...it’s just a really bad idea

Upvotes: 1

Related Questions