With the latest 4D updates, we’ve extended the Session command to the Client/Server connection, enabling access to session storage at the Client level. Pairing this functionality with the new ‘Restrict’ event in ORDA classes makes filtering results based on session data—such as privileges, roles, or even geographic areas—easier than ever.
Developing an application in 4D meant working in a local environment, such as a single user. In standalone mode, the Session command always returned Null. This meant that you had to write complex code, checks whether the Session object was Null to read from “Storage” or “Session.storage”. This workaround, while functional, was not elegant.
With 4D 20 R8, this is no longer an issue. The Session command now returns a valid object, even in standalone mode, simplifying application development and testing.
Extended commands in standalone
With the notion of Session available in development, these 3 commands can now be used:
It’s important to note that the session created in a single-user environment is a simulated session. These commands should only be used to develop and test Client/Server applications to simplify your workflow.
In standalone applications, you continue to use the Storage command to retain user-specific information for use with the “Restrict” event, for example.
Practical use cases
Let’s explore some practical use cases for the session object, made simpler by the new feature introduced in this version of 4D.
Authentification
When authenticating a user with the “authentify” function, you can save information about the user within the Session object.
For further insights, check out these blogs:
- Improved 4D Client Licenses Usage with Qodly Studio for 4D
- Force Login Becomes Default for all REST Auth
Data restriction
With the “Restrict” event, you can protect your data depending on who accesses it and which data is accessed, and ensure data security by restricting access.
For more details, read this blog: ORDA – Restrict Data to Relevant Criteria
Shared data between sessions
Each session maintains its own storage. You can also access the storage of another session.
So the same user can access their storage from both the desktop client application, and the web application. Consequently, it’s very easy to start work on one device and continue on another, such as transitioning from your computer to a tablet, while keeping the same preferences.
To learn more, explore these blogs:
- New 4D remote session object with Client/Server connection and Stored procedure
- Enhanced Session Storage Access
Dive Deeper
If you want to learn more about all the different types of sessions, I recommend you read the pages on Web sessions, Remote sessions, API sessions, and Privilege sessions.
Don’t hesitate to share your experiences in the forum.