NetTalk Central

NetTalk Web Server => Web Server - Ask For Help => Topic started by: Poul on March 03, 2017, 09:00:48 AM

Title: p_web.SetSessionLoggedIn(0) for a WebserviceMethod
Post by: Poul on March 03, 2017, 09:00:48 AM
Currently at the end of each ServiceMethod I am adding  code to kill my session.
Without it, i must rely on the session timeout which keeps many sessions opens for no good reason
as i will not reuse the session. All to maintain the stateless aspect of a RESTful API.

Code: [Select]
!----------------------------------------------------------------------------------------------------
! All your actual code for this method goes here. The "incoming parameter variables" have been primed
!----------------------------------------------------------------------------------------------------
ServiceMethod  routine
! Start of "Service Method Routine"
! [Priority 4000]
...

  p_web.SetSessionLoggedIn(0)   !<<-- template option?
! End of "Service Method Routine"

! [Priority 1300]
This works fine, but i am lazy and sometimes forget, is there a place where i can embed this once - for all servicemethods , so the session ends immediately after any service method call? Or perhaps more simply can the template give me an option to logoff/end the session and write this line of code?  (or take me to a common wrap up/kill method were i can write this once)

poul



Title: Re: p_web.SetSessionLoggedIn(0) for a WebserviceMethod
Post by: Bruce on March 09, 2017, 05:45:07 AM
Hi Poul,

It's worse than you think.

>> Currently at the end of each ServiceMethod I am adding  code to kill my session.

no you're not. you're adding;

>>  p_web.SetSessionLoggedIn(0)   !<<-- template option?

which just logs the session out. it doesn't delete the session.
(it's possible your session will delete on a logout - that's an option.)

>>  is there a place where i can embed this once - for all servicemethods , so the session ends immediately after any service method call?

no, but I'll look at adding something for you.

cheers
Bruce

Title: Re: p_web.SetSessionLoggedIn(0) for a WebserviceMethod
Post by: Poul on March 09, 2017, 08:02:18 AM
yes , once i added the performance tab, i saw how the sessions where building up,
i had to fiddle with things to get it right , but i can trust the counters, right?

i have delete session on logout = true
I turn off allow keep alive - (probably not needed)

it has been working, so long as i logoff at the end of a servicemethod

- this kind of dedicates the server for the APIs, which in this case i can live with, as i have s separate server for pages..
but i'd rather have the option that each method automatically can simply delete/ clean up everything like it was never there.
Perhaps with the default option set in the NetWebservice not the webMethod that indicates all its methods are stateless?


i tried to find a place in web handler   like getpassword or authenticate
where i also do things like Free(self._CookieQueue) to remove the sessionid.
but its too to soon for logout, as there is stuff  in a netwebmethod that may depend on session data (loggedin state for example)

so It would be great if you could add something, thanks.

poul


Title: Re: p_web.SetSessionLoggedIn(0) for a WebserviceMethod
Post by: Bruce on March 13, 2017, 01:34:34 AM
done for 9.22