Session Package

Introduction
Requirements
Preparing To Use It
Example Usage
Using Sessions From Your Code
Session Configuration Options
Session Methods
Getting Additional Randomness From The Entropy File

Introduction

This is session management code. It provides an interface to allow you to generate and track a browser's visit as a "session", giving you a unique session ID and an interface for storing and retrieving data for that session on the server.

This is an alpha/beta release -- documentation is not in final form, but everything you need should be in this file.

Using sessions and their included ability to store and retrieve session-related data on the server, programmers can generate more secure and higher-performance websites. For example, hidden fields do not have to be included in forms (and the risk of them being manipulated by the user mitigated) since data that would be stored in hidden fields can now be stored in the session cache on the server. Forms are then faster since no hidden data is transmitted -- hidden fields must be sent twice, once in the form to the broswer and once in the response from it.

Robust login systems, etc, can be built on top of this code.

Requirements

Rivet. Currently has only been tested with Postgresql. All DB interfacing is done through DIO, though, so it should be relatively easy to add support for other databases.

Preparing To Use It

Create the tables in your SQL server. With Postgres, do a psql www or whatever DB you connect as, then a backslash-i on session-create.sql

(If you need to delete the tables, use session-drop.sql)

The session code by default requires a DIO handle called DIO (the name of which can be overridden). We get it by doing a

  RivetServerConf ChildInitScript "package require DIO"
  RivetServerConf ChildInitScript "::DIO::handle Postgresql DIO -user www"

Example Usage

In your httpd.conf, add:

RivetServerConf ChildInitScript "package require Session; Session SESSION"

This tells Rivet you want to create a session object named SESSION in every child process Apache creates.

You can configure the session at this point using numerous key-value pairs (which are defined later in this doc). Here's a quick example:

RivetServerConf ChildInitScript "package require Session; Session SESSION \
  -cookieLifetime 120 -debugMode 1"

Turn debugging on -debugMode 1 to figure out what's going on -- it's really useful, if verbose.

In your .rvt file, when you're generating the <HEAD> section:

SESSION activate

Activate handles everything for you with respect to creating new sessions, and for locating, validating, and updating existing sessions. Activate will either locate an existing session, or create a new one. Sessions will automatically be refreshed (their lifetimes extended) as additional requests are received during the session, all under the control of the key-value pairs controlling the session object.

Using Sessions From Your Code

The main methods your code will use are:

SESSION id
After doing a SESSION activate, this will return a 32-byte ASCII-encoded random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a request within the timeout period, this same string random hexadecimal string. Every time this browser comes to us with a r