HTTP Session

HTTP Session object provided to the scripting services implementation to hold session attributes for multiple client requests.

Version 3.x

Basic Usage

1
2
3
4
5
6
7
8
9
var session = require('http/v3/session');
var response = require('http/v3/response');

session.setAttribute("attr1", "value1");
var attr = session.getAttribute("attr1");

response.println("[Attribute]: " + attr);
response.flush();
response.close();

Definition

Functions


Function Description Returns
isValid() Returns true if the current execution context is in a HTTP call boolean
getAttribute(name) Returns the HTTP session attribute by name string
getAttributeNames() Returns all the HTTP session attributes names array of string
getCreationTime() Returns the time when the HTTP session has been initialized Date
getId() Returns the HTTP session ID string
getLastAccessedTime() Returns the time when the HTTP session has been last accessed Date
getMaxInactiveInterval() Returns the maximum inactive interval of this HTTP session int
invalidate() Invalidates this HTTP session -
isNew() Returns true, if the HTTP session is created during this HTTP call and false otherwise boolean
setAttribute(name, value) Sets the HTTP session attribute by name and value string
removeAttribute(name) Removes the HTTP session attribute by name string
setMaxInactiveInterval(interval) Sets the maximum inactive interval of this HTTP session -

Compatibility

Rhino Nashorn V8
βœ… βœ… βœ…


Version 2.x

Basic Usage

1
2
3
4
5
6
7
8
9
10
11
12
/* globals $ */
/* eslint-env node, dirigible */

var session = require('net/http/session');
var response = require('net/http/response');

session.setAttribute("attr1", "value1");
var attr = session.getAttribute("attr1");

response.println("[Attribute]: " + attr);
response.flush();
response.close();

Definition

Functions


Function Description Returns
getAttribute(name) Returns the HTTP session attribute by name string
setAttribute(name, value) Sets the HTTP session attribute by name and value string
removeAttribute(name) Removes the HTTP session attribute by name string
getAttributeNames() Returns all the HTTP session attributes names array of string
getId() Returns the HTTP session ID string
getCreationTime() Returns the time when the HTTP session has been initialized Date
getLastAccessedTime() Returns the time when the HTTP session has been last accessed Date
getMaxInactiveInterval() Returns the maximum inactive interval of this HTTP session int
setMaxInactiveInterval(interval) Sets the maximum inactive interval of this HTTP session -
invalidate() Invalidates this HTTP session -

Compatibility

Rhino Nashorn V8
βœ… βœ… ❌
Edit