4D Blog

Home Product New 4D remote session object with Client/Server connection and Stored procedure

New 4D remote session object with Client/Server connection and Stored procedure

May 3, 2024

Product

In 4D applications, four types of sessions exist 4D Remote session, Stored Procedure session, Mobile session, and Web session.

The Session command already returns Web or Mobile sessions. This gives you access to a wealth of information about the session and an object shared by all processes in the session.

In 4D 20 R5, the Session command has been extended to the Client/Server connection and stored procedure.

HDI – Remote session

4D session

Different type

The definitions of a stored procedure session or a remote session are:

Stored Procedures session

When you call a method with the Execute on server command, 4D creates a “Stored procedure” process. All “Stored procedure” processes belong to the same session, which is dedicated to stored procedures.

Remote session

Methods with the “Execute on server” property are executed in the twin client process on the server. All client twin processes are executed in the same session.

Session class

For a remote session or a stored procedure session, the Session command returns a 4D.Session object containing the following properties:

  • id – Unique identifier of the session
  • info – All information about the session
  • storage – A shared object that can be used to store information available to all processes of the remote session
  • userName – The user name associated with the session

 

The same functions of the Web session are available for writing generic code. But do nothing and return always the same value. We invite you to see the documentation of the Session class.

Example:

{
    "id": "B022A91187EF46C6B4D58C2A9BDE3C91",
    "info":{
        "type": "remote",
        "userName": "Designer",
        "machineName": "John Computer",
        "systemUserName": "John Doe",
        "IPAddress": "localhost",
        "hostType": "mac",
        "creationDateTime": "2024-03-27T10:11:31Z",
        "state": "active",
        "ID": "B022A91187EF46C6B4D58C2A9BDE3C91",
        "persistentID": "24336199BADF4BFE945B109E565D1189"
    },
    "storage": {
        "settings": {
            "text": "test"
        }
    },
    "userName": "Designer"
}

Share data between processes

When a new session is created, the “Session.storage” property shall be instantiated with an empty shared object. Then, you can store any data you want to share between processes in the same session.

Use (Session.storage)
 Session.storage.settings:=New shared object("property"; $value; "property2"; $value2)
End use

Use cases

User authentication and verification process

You launch a user authentication and verification procedure when a client connects to the server. For example, this may involve entering a code sent by e-mail or SMS into the application. You then add the user information to the session storage, enabling the server to identify the user. This way, the 4D server can access user information for all client processes, enabling customized code to be written according to the user’s role (e.g., manager, HR, etc.).

Restrict data

With this new session type, you can restrict the data displayed to the connected user. For example, in a customer management application, the sales representative only has access to his customer data. All the information on this new feature is explained in this blog.

Next

Feel free to join us on the 4D Forum if you have any questions or want to share your experience or use cases. 

Discuss

Tags 20 R5, 21, Class, Client/Server, Network, Programming, Session

Latest related posts

  • June 16, 2025

    Generate, share and use web sessions One-Time Passcodes (OTP)

  • May 20, 2025

    Automatic Refresh of OEM Build Licenses

  • May 16, 2025

    New class to handle incoming TCP connections

Vanessa Talbot
Vanessa Talbot
• Product Owner •Vanessa Talbot joined 4D Program team in June, 2014. As a Product Owner, she is in charge of writing the user stories then translating it to functional specifications. Her role is also to make sure that the feature implementation delivered is meeting the customer need.Since her arrival, she has worked to define key features in 4D. She has worked on most of preemptive multi-threading new features and also on a very complex subject: the new architecture for engined application. Vanessa has a degree from Telecom Saint-Etienne. She began her career at the Criminal Research Institute as a developer for the audiovisual department. She has also worked in media and medical fields as expert in technical support, production as well as documenting new features.
  • Deutsch
  • Français
  • English
  • Português
  • Čeština
  • Español
  • Italiano
  • 日本語

Categories

Browse categories

  • 4D View Pro
  • 4D Write Pro
  • 4D for Mobile
  • Email
  • Development Mode
  • 4D Language
  • ORDA
  • User Interface / GUI
  • Qodly Studio
  • Server
  • Maintenance
  • Deployment
  • 4D Tutorials
  • Generic
  • 4D Summit sessions and other online videos

Tags

4D-Analyzer 4D for Android 4D for iOS 4D NetKit 4D Qodly Pro 4D View Pro 4D Write Pro 20 R8 20 R9 Administration Authentication Build application CI/CD Class Client/Server Code editor Collections Compatibility settings Formula Listbox Logs Mail Microsoft 365 Network Objects ORDA PDF Pictures Preemptive Programming Qodly Studio REST Scalability Security Session Source control Speed Spreadsheet Tutorial UI User Experience v20 vscode Web Word processor

Tags

4D-Analyzer 4D for Android 4D for iOS 4D NetKit 4D Qodly Pro 4D View Pro 4D Write Pro 20 R8 20 R9 Administration Authentication Build application CI/CD Class Client/Server Code editor Collections Compatibility settings Formula Listbox Logs Mail Microsoft 365 Network Objects ORDA PDF Pictures Preemptive Programming Qodly Studio REST Scalability Security Session Source control Speed Spreadsheet Tutorial UI User Experience v20 vscode Web Word processor
Subscribe to 4D Newsletter

© 2025 4D SAS - All rights reserved
Terms & Conditions | Legal Notices | Data Policy | Cookie Policy | Contact us | Write for us


Subscribe to 4D Newsletter

* Your privacy is very important to us. Please click here to view our Policy

Contact us

Got a question, suggestion or just want to get in touch with the 4D bloggers? Drop us a line!

* Your privacy is very important to us. Please click here to view our Policy