Session variables and site security

I’m trying to understand session variables as I feel I never used them properly. In Dreamweaver I would use MM_Username a lot to filter tables and return data based on the user. MM_Username was the only thing I Ever used because I didn’t really know how it was set to begin with.

Is it possible to set more session variables based on a users login? and how do I correctly use these variables to filter my data inn wappler. Is it more appropriate to use the site security setting to filter and link data on my page? Do I filter my data on the page side or the server connect side?

I’m sorry, I’m guessing this is fundamental but I would rater learn to do this right from the start

Hello @rokit,
You don’t need to deal with sessions the way you did in DW in order to filter data.

Here it is explained how to use the logged user ID to filter a query: Getting Details of the Logged In User and Binding them to your page and it is done on the server side (in server connect). The identity is available just right after the security provider step.

OK thanks, I did that tutorial and created the page already. I can display the login data from the user table just fine… Now I want to display data from another table (in this example it is their team) How do I make the team data for that user show up?

In the past I could use their e-mail using the session variable. (e-mail is a field in the team table) Do I set up a “team details” in the server connect side using the same method? I “think” I’ve tried that but I was unable to return data, I stopped because I wasn’t sure.

Please check this: Using Session Variables

Define the session in the action where you get user details, then use set session step and assign a value to it.
Then just define this session (under Globals) in every server action you need it, and use it in the queries.

OK, very good I think you are clearing this up for me, I’ll test it out. So if I wanted to set a session for the user I could define the session name with their user ID and if I also wanted to define their team I could also set a session variable for their team in the same place?

Yes, you need two set session steps to set values for each of them.

Then, in the server actions where their values are going to be used in the data picker, you need to just define the sessions under Globals > $_SESSIONS :slight_smile:

Thank you. It may seem insignificant but this is something that I’ve wanted to do for YEARS but never had the time to really research it as the Dreamweaver help gets buried in all of their other products. With Wappler the tools are more intuitive for learning how these things are built along with the availability of your help here and the ever growing research library I am excited to learn new things every day. I really appreciate your help

1 Like

I used set session in the user details action and I cannot pick from data in the query??

You need to add a repeat step after the query. Select the query as a value for the repeat. Put the set session steps in the repeat steps.
Now you will be able to bind the data.

1 Like

OH so cool, got this working! Thanks

1 Like