Whitebeam Template Reference Documentation

Site Map
 
Home
 
Application Guide
Reference
  Installation
  Configuration
  XML Markup
  JavaScript Classes
  ROM
  Templates
  Environment
  Dev Process
  Tools
  External Links
  Example libraries
Community
Contact Whitebeam
To-Do
Download
Credits
Licence
Whitebeam Users
 
 
 

Whitebeam Template Reference Documentation

System Template

session.url()

Add the Whitebeam session ID into the URL provided.

Syntax

string = rb.page.session.url(url, escapeAmp)

Parameters

The 'session.url' method takes 2 parameters:

Name Type/Value Range/Length Description
urlstring  Required. The basic URL to encode with the Whitebeam session ID.
escapeAmpbool  Optional, default = true
Whether ampersands inserted into the modified URL should be escaped

Results

The 'session.url' method returns string:

Type/Value Range/Length Description
string  Return a URL including the Whitebeam 'session ID' marker.

Remarks

This method allows the web designer to store application specific data against the users session. That information can be subsequently retrieved using the rb.page.session.read method.

For this mechanism to work the Presentation Engine assigns each session a unique ID. The value of the ID is not important - it is however important that with each page requested by a client - that ID can be retrieved.

Two mechanisms are used. Firstly the Presentation Engine embeds the ID in a special Whitebeam client side cookie. This is the prefered mechanism and it will always work provided the client has cookies enabled.

If a client wants to ensure that the ID is correctly maintained for clients that do not allow cookies the ID must be embedded in all URLs that refer back to the same site. The encoding of this is to add the parameter onto the URL as a 'GET' parameter. The format of this encoding can be seen as follows:

Original URL

../test/page.rhtm

Encoded URL

../test/page.rhtm?Red60urne=412-45HDFJEWSD

This method will always return a JavaScript object. If no data has been stored with the session then the object will contain no properties. You cannot test for the presence of session data by testing whether or not the result is undefined!

Example

This example reads the session data, checks for a 'userInfo' are and if not present creates it. Finally it writes the modifications back to the system template so they are available the next time the a page in the site is accessed.

<rb:script>
   // Read any existing session data.
   var sessionData = rb.page.session.read();

   // Check to see whether there is a 'user' object already.
   if (!sessionData.userInfo) {
      // No data - create it
      sessionData.userInfo = new Object;
      sessionData.userInfo.name = "Fred";
      sessionData.userInfo.id   ="44523";
   }
   // Finally store the session data ready for the next access.
   rb.page.session.write(sessionData);
</rb:script>

Note this is the recommended way of using session data.

  • Read the current contents of the object.
  • Make modifications for this page.
  • Finally write the data back to the template.
Whitebeam release 1.3.36
(loadtime : 187ms)