---
sourceDocument: Xanadu API Reference
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/xanadu/api-reference

 Release :

    - xanadu

ft:locale :

    - en-US

ft:publication_title :

    - Xanadu API Reference

ft:clusterId :

    - crapiref

bundleId :

    - crapiref

workflow :

    - Creator


---

# GlideSession - Scoped

# GlideSession - Scoped {#ariaid-title1}

* Release version: Xanadu
* 
* Updated August 1, 2024
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 3 minutes to read

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.

## Scoped GlideSession - getClientData(String paramName) {#ariaid-title2}

Retrieves a session client value previously set with
putClientData().
Use this method to retrieve data values that were set using the
putClientData() method.
{#r_ScopedGlideSessionGetClientData_String__table_j24_fqk_ls__entry__3}

| Name | Type | Description |
|-|-|-|
| paramName | String | Name of the client data to retrieve. |
[Table 1. Parameters]

{#r_ScopedGlideSessionGetClientData_String__table_j24_fqk_ls} {#r_ScopedGlideSessionGetClientData_String__table_k24_fqk_ls__entry__2}

| Type | Description |
|-|-|
| String | Client data. |
[Table 2. Returns]

{#r_ScopedGlideSessionGetClientData_String__table_k24_fqk_ls}  

    var session = gs.getSession();
    session.putClientData('test1', 'Harry');
    var clientData = session.getClientData('test1');
    gs.info(clientData);

Output:

    Harry

## Scoped GlideSession - getClientIP() {#ariaid-title3}

Returns the client IP address.
{#r_ScopedGlideSessionGetClientIP__table_gcx_wqk_ls__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 3. Parameters]

{#r_ScopedGlideSessionGetClientIP__table_gcx_wqk_ls} {#r_ScopedGlideSessionGetClientIP__table_hcx_wqk_ls__entry__2}

| Type | Description |
|-|-|
| String | IP address. |
[Table 4. Returns]

{#r_ScopedGlideSessionGetClientIP__table_hcx_wqk_ls}  

    var session = gs.getSession();
    var addr = session.getClientIP();
    gs.info(addr);

Output:

    50.59.164.97

## Scoped GlideSession - getCurrentApplicationId() {#ariaid-title4}

Returns the application currently selected in the application picker.
This method requires admin privileges.
{#r_ScopedGlideSessionGetCurrentApplicationId__table_br3_jrk_ls__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 5. Parameters]

{#r_ScopedGlideSessionGetCurrentApplicationId__table_br3_jrk_ls} {#r_ScopedGlideSessionGetCurrentApplicationId__table_cr3_jrk_ls__entry__2}

| Type | Description |
|-|-|
| String | Currently selected application. |
[Table 6. Returns]

{#r_ScopedGlideSessionGetCurrentApplicationId__table_cr3_jrk_ls}  

    var session = gs.getSession();
    var appID = session.getCurrentApplicationId();
    gs.info(appID);

Output:

    ce05b9f32b840200c5244f74b4da1501

## Scoped GlideSession - getCurrentDomainID() {#ariaid-title5}

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.
{#GSS-getCurrentDomainID__table_jcl_vvq_xnb__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 7. Parameters]

{#GSS-getCurrentDomainID__table_jcl_vvq_xnb} {#GSS-getCurrentDomainID__table_kcl_vvq_xnb__entry__2}

| Type | Description |
|-|-|
| String | Sys_id of the session domain of the current logged-in user. This is the same information that appears in the domain picker. |
[Table 8. Returns]

{#GSS-getCurrentDomainID__table_kcl_vvq_xnb}  
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() {#ariaid-title6}

Returns the session's language code.
{#r_ScopedGlideSessionGetLanguage__table_chb_wrk_ls__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 9. Parameters]

{#r_ScopedGlideSessionGetLanguage__table_chb_wrk_ls} {#r_ScopedGlideSessionGetLanguage__table_dhb_wrk_ls__entry__2}

| Type | Description |
|-|-|
| String | Session's language code. |
[Table 10. Returns]

{#r_ScopedGlideSessionGetLanguage__table_dhb_wrk_ls}  

    var session = gs.getSession();
    var language = session.getLanguage();
    gs.info(language);

Output:

    en

## Scoped GlideSession - getSessionToken() {#ariaid-title7}

Returns the session token.
{#r_ScopedGlideSessionGetSessionToken__table_g2l_gsk_ls__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 11. Parameters]

{#r_ScopedGlideSessionGetSessionToken__table_g2l_gsk_ls} {#r_ScopedGlideSessionGetSessionToken__table_h2l_gsk_ls__entry__2}

| Type | Description |
|-|-|
| String | Session token. |
[Table 12. Returns]

{#r_ScopedGlideSessionGetSessionToken__table_h2l_gsk_ls}  

    var session = gs.getSession();
    var token = session.getSessionToken();
    gs.info(token);

Output:

    4284b5372b840200c5244f74b4da15f2c3476cf7fcb6572afa4ef9d5e6d307a5fd9e1da7

## Scoped GlideSession - getTimeZoneName() {#ariaid-title8}

Returns the name of the session's time zone.
{#r_ScopedGlideSessionGetTimeZoneName__table_tws_qsk_ls__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 13. Parameters]

{#r_ScopedGlideSessionGetTimeZoneName__table_tws_qsk_ls} {#r_ScopedGlideSessionGetTimeZoneName__table_uws_qsk_ls__entry__2}

| Type | Description |
|-|-|
| String | Name of the session's time zone. |
[Table 14. Returns]

{#r_ScopedGlideSessionGetTimeZoneName__table_uws_qsk_ls}  

    var session = gs.getSession();
    var zoneName = session.getTimeZoneName();
    gs.info(zoneName);

Output:

    US/Pacific

## Scoped GlideSession - getUrlOnStack() {#ariaid-title9}

Returns the URL on the stack. Returns null if the stack is empty.
{#r_ScopedGlideSessionGetUrlOnStack__table_qhx_ctk_ls__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 15. Parameters]

{#r_ScopedGlideSessionGetUrlOnStack__table_qhx_ctk_ls} {#r_ScopedGlideSessionGetUrlOnStack__table_rhx_ctk_ls__entry__2}

| Type | Description |
|-|-|
| String | URL on the stack. Returns null if the stack is empty. |
[Table 16. Returns]

{#r_ScopedGlideSessionGetUrlOnStack__table_rhx_ctk_ls}  

    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() {#ariaid-title10}

Returns true if the user is impersonating another user.
{#r_SGSSN-isImpersonating__table_rhv_tj5_xw__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 17. Parameters]

{#r_SGSSN-isImpersonating__table_rhv_tj5_xw} {#r_SGSSN-isImpersonating__table_shv_tj5_xw__entry__2}

| Type | Description |
|-|-|
| Boolean | Flag that indicates the user is impersonating another user. Possible values: * true: User is impersonating. * false: User isn't impersonating. |
[Table 18. Returns]

{#r_SGSSN-isImpersonating__table_shv_tj5_xw}  

    var isImpersonator = gs.getSession().isImpersonating();
    gs.info(isImpersonator);

## Scoped GlideSession - isInteractive() {#ariaid-title11}

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.
{#r_ScopedGlideSessionIsInteractive__table_fjc_dpk_ls__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 19. Parameters]

{#r_ScopedGlideSessionIsInteractive__table_fjc_dpk_ls} {#r_ScopedGlideSessionIsInteractive__table_gjc_dpk_ls__entry__2}

| Type | Description |
|-|-|
| Boolean | Flag that indicates whether the session is interactive. Possible values: * true: Session is interactive. * false: Session isn't interactive. |
[Table 20. Returns]

{#r_ScopedGlideSessionIsInteractive__table_gjc_dpk_ls}  

    var interActive = gs.getSession().isInteractive();
    gs.info(interActive);

## Scoped GlideSession - isLoggedIn() {#ariaid-title12}

Returns true if the user is logged in.
{#r_ScopedGlideSessionIsLoggedIn__table_phb_qpk_ls__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 21. Parameters]

{#r_ScopedGlideSessionIsLoggedIn__table_phb_qpk_ls} {#r_ScopedGlideSessionIsLoggedIn__table_qhb_qpk_ls__entry__2}

| Type | Description |
|-|-|
| Boolean | Flag that indicates whether the user is logged in Possible values: * true: User is logged in. * false: User isn't logged in. |
[Table 22. Returns]

{#r_ScopedGlideSessionIsLoggedIn__table_qhb_qpk_ls}  

    var session = gs.getSession();
    var loggedIn = session.isLoggedIn();
    gs.info(loggedIn);

Output:

    true

## Scoped GlideSession - putClientData(String paramName, String paramValue) {#ariaid-title13}

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.
{#r_ScopedGlideSessionPutClientData_String_String__table_cgh_ytk_ls__entry__3}

| Name | Type | Description |
|-|-|-|
| paramName | String | Name of the client data to set. |
| paramValue | String | Value of the client data. |
[Table 23. Parameters]

{#r_ScopedGlideSessionPutClientData_String_String__table_cgh_ytk_ls} {#r_ScopedGlideSessionPutClientData_String_String__table_dgh_ytk_ls__entry__2}

| Type | Description |
|-|-|
| void |   |
[Table 24. Returns]

{#r_ScopedGlideSessionPutClientData_String_String__table_dgh_ytk_ls}  

    var session = gs.getSession();
    session.putClientData('test1', 'Harry');
    var clientData = session.getClientData('test1');
    gs.info(clientData);

Output:

    Harry


