KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Obtain web user session ID with REST
PRODUCT: 4D | VERSION: 18 | PLATFORM: Mac & Win
Published On: July 12, 2021

When developing web processes, sometimes the web user’s session ID must be obtained. The session ID can be pulled from the HTTP header. Alternatively, you can use 4D REST API to grab the session ID. Simply call a GET method using the /rest/$info API. It will return a JSON object that includes a collection of sessionInfo objects. Within a particular sessionInfo object, there is a sessionID property, along with other useful properties such as username, user ID, and session expiration date. Note that after a successful login with REST API, if you are using a JavaScript method such as fetch(), the session cookies may need to be resent in the headers for subsequent REST calls (using something like credentials: ‘include’ in the init object). Otherwise, you may receive a 401: Unauthorized error.