Session.set(options)

Note:

The content in this help topic pertains to SuiteScript 2.0.

Method Description

Sets a key and value for a user-defined session object.

Use Session.get(options) to retrieve the object value after you set it.

Returns

void

Supported Script Types

Server scripts

For more information, see SuiteScript 2.x Script Types.

Governance

None

Module

N/runtime Module

Since

2015.2

Parameters
Note:

The options parameter is a JavaScript object.

Parameter

Type

Required / Optional

Description

Since

options.name

string

required

Key used to store the session object.

2015.2

options.value

string

required

Value to associate with the key in the user session.

2015.2

Errors

Error Code

Thrown If

SSS_MISSING_REQD_ARGUMENT

The options.name or options.value parameter is not specified.

Syntax
Important:

The following code sample shows the syntax for this member. It is not a functional example. For a complete script example, see N/runtime Module Script Samples.

          // Add additional code 
...
var sessionObj = runtime.getCurrentSession();
sessionObj.set({
    name: 'myKey', 
    value: 'myValue'
});
log.debug('Session object myKey value: ' + sessionObj.get({name: 'myKey'}));
...
// Add additional code 

        

Related Topics

runtime.Session
N/runtime Module
SuiteScript 2.x Modules
SuiteScript 2.x

General Notices