KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Using scalable sessions with cross-origin requests
PRODUCT: 4D | VERSION: 19 | PLATFORM: Mac & Win
Published On: April 24, 2023

When developing a web application, scalable sessions is a useful option for handling multiple simultaneous requests from a user. When scalable sessions are enabled, 4D sets a session cookie to keep track of opened sessions for clients, and the Session command returns session objects to manage user session information. If the web application makes any cross-origin requests, such as with Fetch API, the web server must have Cross-Origin Resource Sharing (CORS) enabled. When CORS is enabled, remember that user credentials (e.g. the session cookie) are not included in cross-origin requests by default. This means that each request to 4D web server will be treated as a new session, because the session cookie is not included in the request header. Thus, the Session.storage object will appear empty, and any stored information will not persist, unless some additional configurations are made to the request, like adding “credentials: ‘include’” to a Fetch API request, for example.