Hi everyone, hope someone can spot what i am doing wrong, never used sessions within Wappler before and must be doing something wrong. I am trying to insert user location detail into an audit record but don’t want to use $_GET parameters
Here is what i have done
Created session variables within app connect session manager
Hey Brian,
This step is not related to passing sessions to server action. It's used to cache server action data into a session (so on refresh the server action is not being called again) and i doubt you need it.
Now on your issue:
How and when do you run the server action on the page?
In answer to your last question, how do i do that? Don;t mind how i do this, just want a working solution. I would really appreciate your assistance on this one.
The 403 is a missing image
Ok i checked your site more detailed, but if you want to use sessions (instead of get vars) you need to change the logic a bit.
Let me just clarify what the workflow should be here
First, you need to have the user ip, lat and lon to be able to use them wherever you need them. So the logic should be:
Wait for the geolocation plugin to get ip, lat, lon
When you have these, set them in variables
Run your server action
So the load event is not suitable here. Auto running action which inserts data is also not suitable.
You need to:
Set server action that inserts data to No Auto Load
Add geolocation plugin
Use geolocation plugin dynamic events > on success:
– Set Session (3 times for the 3 values)
– Run the insert Server Action
This way the location data will be collected, sessions will be created, the action will be called and session values will be inserted with insert step
Hope that helps.
The server action now runs when the location has been detected. Everything should be inserted perfectly.
Please create 3 setvalue steps in your server action and bind each session value to them (enable output as well) so i can check what the sessions return.
There is no need for them to be in a repeat - just 3 regular steps at the begging of the file will do it.
Just a question - are you using the latest version of Wappler, as in previous versions there was an issues passing {{$_SESSION.name_here}} in server connect steps?
The IP is critical, the lat. lng is a bonus. I assume if I create a $_SERVER.REMOTE_ADDR in server action it will give the server address and not the client address as the script is called from app connect (or have i got that wrong)?
Just the record make sure you save a server action to update server connect files to the latest, as we did fix some server connect issues with $_SESSION in PHP