How do I assign a database column / query value to a session?

I can’t seem to find to how to assign a database query field value to a session, I got this far as to create the session name, but don’t see where I can bind a field to it.

All I see in properties below in my screenshot is a Linked Field area, which I expected to have something to click to the right of it to see queries etc… to click on, see the field in the query and bind it, but maybe I’m just not on the right track for this.

What are the steps I need to do this?

In classic asp all I need to do after a queryis something like the following:
Session(“session_first”) = (rsUser.Fields.Item(“first_name”).Value)

Hi Amedeo,

You use the Set Session action to assign a value, like this:

Thanks, but I must be missing something, I still don’t see where I can select my field from my query.

Here’s a basic setup:

You query the database and then repeat through each of the rows that are returned by the query. In that repeat you can do anything you want for each of those items.

Now, what I do when I only expect a single row to be returned, is I bypass the repeat all together like this:

Which is just specifying the index of the queryBanks array, and then referencing the column name.

If you are looking for the information of a logged-in user, then have a look at https://docs.wappler.io/t/getting-details-of-the-logged-in-user-and-binding-them-to-your-page/2850

Hi Ben,

Thanks, I have that part working where I can access the logged in user data. But I need to display certain data in other pages so to avoid re accessing the database I wanted to set a few sessions once a user is logged in so i can access those session values in other pages.

Thanks, I tried to key in the code since I still don’t see a place where I can select the actual field.

In trying to display the session value however It’s blank so i must still have something wrong.

Use sessions on the client side (App Connect) as per https://docs.wappler.io/t/passing-values-between-your-pages/5588

I think you are conflating user sessions from the server and sessions on the client…they are distinct and separate. If you want to display this on the client, you can just set to Output on the query itself, which will then be available to bind at the client. If you really are in need of session stuff…take a look at the docs for an explanation.

Sometimes the hardest part of Wappler is letting go of old habits and embracing a new way of working.
But if you really need to do this then your syntax {{session_first}} wont work, you need to reference a server session in app connect via scripting i.e. <?php echo $_SESSION["session_first"];?> but frankly just returning values from a server action a much better way

1 Like

Brian, you are correct, I’m coming from CS6, classic asp so this is a whole new way of thinking. Some needs to write a Wappler How to Book. :slight_smile:

Thanks, just adding the php code you have above retrieved my session value.