System Template
session.writeByPublicKey()
- Available since version 1.3.6
Write data to sessions identified by a public key
See Also
rb.page.session.setPublicKey() Syntax
number = rb.page.session.writeByPublicKey(publicKey, dataSectionName, data)
Parameters
The 'session.writeByPublicKey' method takes 3 parameters:
Name | Type/Value | Range/Length | Description | publicKey | number | signed 64 bit integer | Required. The public key identifying foreign sessions | dataSectionName | string | string starting with '$' | Required. The session data receptor into which to store the data | data | MetaData | | Required. A Javascript object to be serialised and stored in matching sessions |
Results
The 'session.writeByPublicKey' method returns number:
Type/Value | Range/Length | Description |
number |
  | Number of active sessions to which data was written
|
Remarks rb.page.session.setPublicKey() assigns
a 64 bit 'public key' to the current session - that is the session of the current HTTP request. The public key effectively advertises the presence of that session to other sessions and allows
a mechanism by which other sessions can write data into the session storage of this session. The documentation for rb.page.session.write
describes how the storage for each session is partitioned into separate named spaces, or sections. Each of these
are individually addressable by the owning session (and only the owning session). This method (writeByPublicKey) allows an application to write data remotely into other active sessions, identified
by the public keys assigned to those sessions. Allowing free access to the session data is a security risk - this would allow a rogue
application to potentially write into sensitive data areas of the stored session data. For this reason Whitebeam
reserves all name spaces starting with '$' as being accessible between sessions. rb.page.session.writeByPublicKey allows an application to write to any named section starting with a '$' in all
sessions that share the specified public key. An error is thrown if you attempt to write to a section name that does *not* start with a '$'. It is possible for foreign sessions to read the 'public' $ named sections of session data via a context server request (rb.context.getContexts)
and so applications must take care about the data they store in these name spaces. |