Display Session Value on Frontend

Hello, I’m new to Wappler and I’m trying to do something very simple. Can someone help me?
I need to display the value of a session variable I created in the backend on the frontend. I can not have button to display it, so I need to keep the auto load serverconnect as default on my user page.
What am I doing wrong?


First, I tried to fetch it using a session storage manager. This way, I can locate the value, but it doesn’t show up on the frontend.

Then, I tried to fetch it using the server connect, but I can’t select the value I set.

Thank you. :slight_smile:

Hi Mariana,

I think "Session Storage Manager" refers to client-side sessions, not server-side ones. With that in mind, you can forget that approach.

Your Server Connect approach would work, but it's weird you're not seeing the token_passaporte variable. I noticed in you first screenshot the file is not saved (there's a blue icon in the tab) - have you actually saved the file?

And then try to select again the Server Action in your Server Connect element properties.

Hi Apple,
Thank you for enlightening me about Session Storage Manage.
Yes, I saved the file 1 million times hahaha
I recreated the API a few times too, thinking it might be some bug. But the variable doesn't appear to me in the front, even though its output is marked in the back. :exploding_head:

Oh, I think I understand the issue now. Maybe Set Session doesn't return a value at all!

After the Set Session step, put a Set Value step with the expression $_SESSION.token_passaporte

1 Like

Just chipping in what if you hard-code a 'temporary' session value and see if that is echoed just to check the session is populated with a value? It may be empty and in that case you need to chase that up and insure it is populated with the value you wish to display?

Hello cheese!
I am happy that I got answers on first day of the year :blush:
Yes, I set static values to test that possibility…:smiling_face_with_tear: no success.

1 Like

You mean my set session is not enought to get the value? I need set value after set session?

I think Set Session only sets the session, it doesn't actually return anything to see! So you need a Set Value to "see" the value that was set

Yes, I think so

What you say makes sense.
After add a set value both (set session and set value) appeared :grinning:
Anyway, despite selecting, the values ​​are not loading.
I tested with static value (123), but nothing comes to my page when I go to localhost.
But now I think it will be something simple to solve. I'll try here.
Thank you very much for the help.


Do you have the correct Server Connect link to the API?

Hello Ben. It's a pleasure to talk to you.
This is what I did to Server Connect. Anyway, I can not display the variable value on paragraph.
Should I have done something else about Server Connect link to the API?

This is what I have done, which is similar to your process.

Server side:

Client side:

and HTML:

<label for="title" class="form-label">Title {{scSessionKey.data.sessionKey}} </label>

That's all there is to it. I do not see a reason why this should not work. Maybe create a new API, perhaps the original one was corrupted somehow. :crossed_fingers:

1 Like

Ben, I copied exactly what you did and it ran perfectly. There's definitely something wrong with my old API. I'll redo it.
By the way, it's been challenging to learn Wappler, since I'm not a developer, but it's been amazing.
Thank you very much

3 Likes

@Mariana1, you're taking the right steps in becoming a developer by going with Wappler. Between it's abundant no-code/low-code features and the amazing Wappler community's help, you'll be building cool apps in no time. I was a full blown PHP developer already when I started using Wappler and even I have learned quite a lot since joining this community. Now, I'm not even using PHP anymore and building NodeJS apps which I would have never attempted without Wappler.

Good luck with your project and welcome to the Wappler family.

-Twitch

4 Likes

A "quirk" of Wappler which has always been there.

In Node, setting output to a session variable returns its value.

In PHP, setting output to a session variable declaration does NOT actually output anything.
To get around this i normally add a set value stage immediately after with output set and assign the value of the session to it which outputs the value.

2 Likes

Here it is in pictures

I start with

i run this directly from server connect.

image

The value is returned as null (incorrectly)

I add a set value stage and assign the session value to it.

the output is correct

image