Help with login and session variables

Hi guys,

I am very new to wappler but experienced with full stack dev. Anyhow i am lost with variables and session variables, it’s very confusing and i don’t seem to find a tutorial for what I’d like to achieve.

I just need the user to login using the security provider and then once logged in save the user id in a session variable that I will use for my DB queries.

i think once I will have understood that I will be able to finish my project :slight_smile:

Thank you!

Firstly welcome to Wappler @Stefdec

This is quite simple once you are aware of the security functionality of Wappler. Within the Server Connect Action you will see the following options available to you:

Security Identity (and Security Provider) contain the necessary details you require. Simple apply this to your Action (drag and drop or click). You can then filter by the logged in User details.

Full documentation (the UI in the tutorial is slightly older but the principle is exactly the same):

Full documentation relating to Security and Login:

1 Like

Maybe this will help you:

1 Like

That was a “Just Arrived” or “Fresh out of the oven” video…
Thanks once again @ben!

1 Like

Thank you, all good now.

I have another quick noob question and i should be all set:

I have links with parameters projectId=1, =projectId=2…
when arriving on the page i select the info of the project using the id passed and then i’d like to save the projectId value in a session variable called currenProjectId in order to use it whenever i want.

Here is what i have done but i don’t think the value is saved or I access it properly

Set my session variable in Globals:

Assign a value to it:

then trying to access in another query:

2 Likes

Thank you but i still can’t access currentProjectId it when running a DB query, do i need to pass it again from the client side? it’s so simple when coding and so complicated here :joy: please help me this is driving me nuts

also when doing this:

If get projectId is empty the query should use the session variable currentProjectId that was set before but no, currentProjectId is empty

what are you trying to assign where…
I hope you mean inside the condition of the db query builder
please a screenshot of that action…

sorry didn’t see that… we were writting at the same time…

please add a step setValue to output the $_GET.projectid… Are you sure it has a value?

  • Run it in your browser

Hey,

projectId has a value, my issue is to assign this value to the session variable currentProjectId and be able to access currentProjectId from any other query.

I just need to know how to assign a value to a session variable and access it elsewhere

Thank you :slight_smile:

You mean form inside another api?
give me an example…

*do you execute this api in your browser?? or just testing inside the builder?

Yes in run everything in the browser. With test parameters it’s all fine. Here is a breakdown:

API 1 (getProject): the projectId is passed as url parameter and send to the query, this works fine. The value of projectId is assigned to currentProjectId (session variable) and then the DB query to select the project info is ran using currentProjectId.

AP2 (getProjectProperties): a db query that needs the ID of the project. I want to be able use the session variable currentProjectId in there but i get an error each time in run the query which mean the values is null:

  1. first this:


    but this is just test… nevermind

  2. my friend I’m worried because I always see the query builder with test values…
    You haven’t ever shown here the browser dev console.
    Please show me the browser

And let me see the flow of the projectid… Where do you save it? Do you have a Query manager or just a query?

ok using $_SESSION… worked.

Thanks for your help and patience

1 Like

So, you were just running it inside the query builder…
Glad it works for you
Its just that we are so sure that “every step is well done”… But there is just a comma or a word wrond and screws up everything!
Anyway, try to not take any step as correct and report everything here so we can find what is wrong

1 Like