Scripting Language


/session Identifier
The Sambar Server scripting files (*.stm) have a reference to a /session directory. For example, the following tag is used to login the user "guest" into the magazine demo:

<A HREF="/session/login?RCuser=guest&RCpage=/magazine/welcome.stm">

The /session directive indicates that a DLL function is being requested. In the above example, /session/login corresponds with the internal "login" function. Once the /session function is executed, if an RCpage is specified and no HTML was generated by the function, the page is displayed. In the above example, /session/login attempts to login the user "guest", assuming the function returns SA_SUCCEED, then the magazine welcome page is output.

The /session/login function expects the argument RCuser and an option RCpwd (password parameter). If no RCpwd argument is provided, a password of NULL is expected. /session/login then attempts to login (see config/passwd) the user, sets a cookie for the user for future authentication, and creates a "state" structure associated with the user and maintained by the server.

So as long as the user is logged in (logins timeout after a period of inactivity), any values set with RCS flags (state flags) will be maintained by the server. This is how the demo maintains user information/preferences etc. accross pages -- the demo gets and sets state variables.

There is a second type of variable appropriate for users called profile variables (RCP arguments). This feature is not presently available in the public version of the sambar server. The RCP variables all you to persistently store attributes of a user so that when they login again, the RCP attributes are retrieved from disk (and can be get/set just like RCS attributes). This interface will probably expose this (and document it) in the 4.1 release.

There is a /session/logout function for logging out and releasing the state information held by the server.

System-defined Tags
The categories of system-defined tags include:

  • RCPattribute
    Client profile attribute tag.
    For example, the tag RCPname specifies the "name" attribute from the client profile.
    The user-defined PROFILE event handler is called to fulfile profile requests. Profile attributes are only available for logged in users, and can be used within conditional logic (see below) or for display purposes.

    Example:
    HTML content might be displayed if RCPage > 16 and RCPsex = "M"

  • RCSstate-variable
    Client state variable tag.
    For example, the tag RCSpagetype specifies the "pagetype" state variable from the client's current session.
    State variables are dynamic and extensible; application programmers can both define state variables and assign values to those variables at any time.

    Example:
    An advertisement for golf clubs might be displayed if RCSprevtype = "Sports" and RCPhobby = "Golf"

  • RCEenvironment-variable
    Server environment variable tag.
    For example, the tag RCEdatetime specifies the current date and time.
    The System Administration forms contains a page with all of the system defined environment variables.
    Example:
    A Christmas advertisement might be displayed if RCEmonth = "12"

  • RCVvariable
    Server variable tag.
    For example, the tag RCVcreator displays the creator of the application. All variables are defined in the sysvars.ini configuration file. Using the system administration forms, variables can be changed without restarting the server.

  • RCZmacro
    Server macro definition.
    For example, the tag RCZFINANCE_FOOTER displays the footer string associated with the FINANCE_FOOTER definition found in the macros.ini configuration file. Macros are loaded at system startup and can only be modified by restarting the server.

  • RCXmethod
    Execute a Server RPC.
    For example, the tag RCXhelp lists all user-defined RPCs registered in the system.

  • RCCcgi
    Execute a Server CGI application.
    For example, the tag RCChello.bat foo=111 bar=222 executes the hello.bat CGI application, passing the foo and bar arguments and returns the results of the script in the HTML file in place of the tag. Note: Only arguments provided with the scripted RPC (foo and bar in the above example) are passed to the CGI application.

  • RCWwincgi
    Execute a Server WinCGI application.
    For example, the tag RCWhello.bat foo=111 bar=222 executes the hello.bat WinCGI application, passing the foo and bar arguments and returns the results of the script in the HTML file in place of the tag. Note: Only arguments provided with the scripted RPC (foo and bar in the above example) are passed to the CGI application.

  • RCOobservation-string
    Log the observation string to the observation file.

  • RCifcondition
    RCelse
    RCelseifanother-condition
    RCendif
    Condition tags.
    These tags enable dynamic evaluation of one or more pre-defined conditions. If the condition is found to be TRUE, the code that follows is executed. This can be used, for example, to determine which choices to display to a particular user. As an example, a visitor to your site might be shown more limited options than might a registered user. Condition tags enable you to evaluate a client's status and take varying actions based upon the result of the evaluation.

.stm files
The above scripting language may only be used in files that are identified as Sambar Server Scripted files. By default, the .stm extension indicates that the file contains Sambar Server Scripting. Upon seeing this extension, the server parses the content looking for the scripting tokens/actions defined above.