Use {{$Api.Session_Id}} as model condition?

  • 1
  • Question
  • Updated 2 years ago
I'm trying to add a condition for a model where a given field has a value of {{$Api.Session_Id}}. I'm writing that variable to records I create. However, the use of the condition returns no result. If I hardcode the Session ID (text instead of {{$Api.Session_Id}}), it works. Also tried using the Session ID user attribute, and that didn't work.

FYI, this is on a public site using the public site user.

Any ideas what I'm missing?

Thanks,
Seth
Photo of Seth Leonard

Seth Leonard

  • 662 Points 500 badge 2x thumb

Posted 2 years ago

  • 1
Photo of Seth Leonard

Seth Leonard

  • 662 Points 500 badge 2x thumb
While I'm at it, it appears that $API.Session_Id is unique to a user, not a session (browser). If used with a Public Site User, it's not helpful (different anonymous users will have the same session ID). Anyone know of a way to have a unique ID for the browser session?
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
Seth,

Unfortunately, conditions don't process merge syntax, which is why you're getting the behavior you witnessed.

I don't know enough about browser sessions to help you with the rest.
Photo of Seth Leonard

Seth Leonard

  • 662 Points 500 badge 2x thumb
Thanks, Matt. I ended up building my own random session ID in javascript and then writing it to a model.
(Edited)