NetTalk Central
NetTalk Web Server => Web Server - Ask For Help => Topic started by: Poul Jensen on April 14, 2025, 08:39:08 PM
-
Hi,
I would like to pass a parameter to the NT server like this:
https://myntserver.com?a=x
And then read the value x into a session value in the webserver procedure.
How do I do this?
tia
/Poul
-
p_web.GetValue('a')
-
Tak Niels.
-
Altid :-)
-
What is the earliest point in the app, where I should read the parameter, preferably code that is reached once only per user?
/Poul
-
Let me expand on this:
What I want to achieve, is to call the app with a parameter, read this parameter and change the filenames global variable names, so they point to a specific dataset.
As per the docs re Multiple Data Sets: https://www.capesoft.com/docs/NetTalk14/NetTalkWebBasic.htm#MultipleDataSets, I have tried the webhandler RequestHostSet embed to read the parameter and save it in a session variable.
But next time through the webhandler this is being reset.
So I need some guidance here for the best approach.
tia
/Poul
-
Use the ProcessLink() WebHandled Method, there you can change the database.
Cheers
-
Hi Alberto,
That is what I am using, but at soon as I click the button for the login window, the filename variables are being reset.
Cheers
/Poul
-
Works for me, Poul.
How are you storing the parameter? If you're putting it into a sessionValue, it should be sticky and persist through the login and beyond.
You'll need to set your filename variables EACH TIME your code runs through p_web.ProcessLink in the webhandler (because each pass through there is happening on a new thread), so set the session values the first time (when they're sent as parameters) then use those session values to set the filename variables EACH TIME.
-
p_web.StoreValue('a')
Is the best way to set a session value to a value, because then if the value doesn't exist (as a parameter) it does not overwrite the session value.
I expect you are just overwriting your session value to blank when the value does not exist.
-
You'll need to set your filename variables EACH TIME your code runs through p_web.ProcessLink in the webhandler (because each pass through there is happening on a new thread), so set the session values the first time (when they're sent as parameters) then use those session values to set the filename variables EACH TIME.
That was the missing piece :-)
Thanks Jane.
-
p_web.StoreValue('a')
Is the best way to set a session value to a value, because then if the value doesn't exist (as a parameter) it does not overwrite the session value.
I expect you are just overwriting your session value to blank when the value does not exist.
Thanks Bruce - spot on.