Skip to content
Release: Australia · Updated: 2026-03-12 · Official documentation · View source

GlideSession- Scoped

The scoped GlideSession API provides methods to find information about the current session.

There are no constructors for creating an instance of a scoped GlideSession object. Instead, use the getSession() method of the scoped GlideSystem API.

Parent Topic:Server API reference

Scoped GlideSession - getClientData(String paramName)

Retrieves a session client value previously set with putClientData().

Use this method to retrieve data values that were set using the putClientData() method.

NameTypeDescription
paramNameStringName of the client data to retrieve.
TypeDescription
StringClient data.
var session = gs.getSession();
session.putClientData('test1', 'Harry');
var clientData = session.getClientData('test1');
gs.info(clientData);

Output:

Harry

Scoped GlideSession - getClientIP()

Returns the client IP address.

NameTypeDescription
None  
TypeDescription
StringIP address.
var session = gs.getSession();
var addr = session.getClientIP();
gs.info(addr);

Output:

50.59.164.97

Scoped GlideSession - getCurrentApplicationId()

Returns the application currently selected in the application picker.

This method requires admin privileges.

NameTypeDescription
None  
TypeDescription
StringCurrently selected application.
var session = gs.getSession();
var appID = session.getCurrentApplicationId();
gs.info(appID);

Output:

ce05b9f32b840200c5244f74b4da1501

Scoped GlideSession - getCurrentDomainID()

Returns the sys_id of the current domain for the logged-in user session.

The identifier that is returned depends on the domain type and the instantiation of that domain.

  • If the user is configured in the global domain, and does not use the domain picker to switch domains, the method returns null.
  • If the user uses the domain picker to switch to the global domain, the method returns the string "global".
  • For all other domains, the method returns the sys_id of that domain.
NameTypeDescription
None  
TypeDescription
StringSys_id of the session domain of the current logged-in user. This is the same information that appears in the domain picker.

This example shows the current sys_email record's domain being set to the user's session domain, if the user domain is global or null.

// Set domain based on parent record's domain
setDomain();

// If the domain is global, set to user's domain
if (current.sys_domain == 'global' || current.sys_domain.nil())
   current.sys_domain = gs.getSession().getCurrentDomainID();

function setDomain() {
   if (current.target_table.nil())
      return;

   var d = new GlideRecord(current.target_table);
   if (!d.isValid())
      return;

   if (!d.get('sys_id', current.instance))
      return;

   if (typeof(d.sys_domain) == 'object')
      current.sys_domain = d.sys_domain;

Scoped GlideSession - getLanguage()

Returns the session's language code.

NameTypeDescription
None  
TypeDescription
StringSession's language code.
var session = gs.getSession();
var language = session.getLanguage();
gs.info(language);

Output:

en

Scoped GlideSession - getSessionToken()

Returns the session token.

NameTypeDescription
None  
TypeDescription
StringSession token.
var session = gs.getSession();
var token = session.getSessionToken();
gs.info(token);

Output:

4284b5372b840200c5244f74b4da15f2c3476cf7fcb6572afa4ef9d5e6d307a5fd9e1da7

Scoped GlideSession - getTimeZoneName()

Returns the name of the session's time zone.

NameTypeDescription
None  
TypeDescription
StringName of the session's time zone.
var session = gs.getSession();
var zoneName = session.getTimeZoneName();
gs.info(zoneName);

Output:

US/Pacific

Scoped GlideSession - getUrlOnStack()

Returns the URL on the stack. Returns null if the stack is empty.

NameTypeDescription
None  
TypeDescription
StringURL on the stack. Returns null if the stack is empty.
var session = gs.getSession();
var URL = session.getUrlOnStack();
gs.info(URL);

Output: line breaks added for clarity.

sys_app.do?sys_id=ce05b9f32b840200c5244f74b4da1501&sysparm_goto_url=sys_app.do
%3Fsys_id%3Dce05b9f32b840200c5244f74b4da1501

Scoped GlideSession - isImpersonating()

Returns true if the user is impersonating another user.

NameTypeDescription
None  
TypeDescription
BooleanFlag that indicates the user is impersonating another user.Possible values: - true: User is impersonating. - false: User isn't impersonating.
var isImpersonator = gs.getSession().isImpersonating();
gs.info(isImpersonator);

Scoped GlideSession - isInteractive()

Returns true if the session is interactive.

An interactive session is one that involves an end-user interacting with a user interface that then retrieves information from a server. An example of this type of session is when a user logs in using the log-in screen or uses a form to query a data store. A non-interactive session is one that only involves programmatic interaction with a server such as a SOAP request to retrieve data.

NameTypeDescription
None  
TypeDescription
BooleanFlag that indicates whether the session is interactive.Possible values: - true: Session is interactive. - false: Session isn't interactive.
var interActive = gs.getSession().isInteractive();
gs.info(interActive);

Scoped GlideSession - isLoggedIn()

Returns true if the user is logged in.

NameTypeDescription
None  
TypeDescription
BooleanFlag that indicates whether the user is logged inPossible values: - true: User is logged in. - false: User isn't logged in.
var session = gs.getSession();
var loggedIn = session.isLoggedIn();
gs.info(loggedIn);

Output:

true

Scoped GlideSession - putClientData(String paramName, String paramValue)

Sets a session client value that can be retrieved with getClientData(). This method is used in a server side script that runs when a form is created.

NameTypeDescription
paramNameStringName of the client data to set.
paramValueStringValue of the client data.
TypeDescription
void 
var session = gs.getSession();
session.putClientData('test1', 'Harry');
var clientData = session.getClientData('test1');
gs.info(clientData);

Output:

Harry