Delphi XE2 Datasnap Session Management - Retrieving Session Information After Page Reload

I am trying to determine how to get session information using the Delphi REST DataSnap server.

I know that on the same client page you have access to the current thread session using the TDSSession GetThreadSession method.

However, I want to save the repository data in a session (putData) and still be able to retrieve it when the user moves from page 1 to page2. Currently, if the user moves to another page, the session will be lost and a new one will be created, which will lead to data loss in the session that I previously installed.

I tried playing with TDSSessionManager.SetThreadSession (sessionid) - but I can't get it to work.

I reviewed the well-known technical paper by Marco Cantu, however it does not provide a solution to this problem.

Any help I could handle would be great - even if its just "hey, this topic is covered in Book X".

Thanks!

+6
source share
3 answers

TDSSessionManager.SetThreadSession (sessionid) works with the name Session.sessionname.

Also, make sure your life cycle is set up for the session (as stated in tondrej).

If you reconnect your client. a new session begins. So you want to open your Datasnap connection.

Or you can set the life cycle on the Server and independently complete client sessions.

Edit: stateless break servers. Therefore, you need to save the page where you are on the client. And request the necessary page from the server

+1
source

You need to configure client-side JavaScript to use a cookie to store session information.

See the last part of JavaScript client sessions

If you want the server objects that are active for the session to use the session life cycle.

+1
source

I believe that you need to set the LifeCycle property of your TDSServerClass instance to Session (stateful). From your question, it seems that you are currently using Invocation (stateless).

0
source

Source: https://habr.com/ru/post/920035/


All Articles