InterJinn

Development Framework For PHP

Session System Configuration

The session system is used to store data about a visitor for the duration of their visit. The duration of their visit is terminated when they close their browser, or when the session times out. The session system requires that the user has enabled temporary cookies. If the user has not then a new session will be created every time the visitor accesses a page. This is true for anything but form submissions which carry the session information forward in the submission so that validation can occur. Since not everyone has a MySQL database server, there exists two core types of session service -- database and file system based. You should look to the appropriate configuration section below for which applies to your project.

Database Session System

$GLOBALS['interJinn']['sessionSystem']

Set this to database to enable the database session system.

Example:
$GLOBALS['interJinn']['sessionSystem'] = 'database';

$GLOBALS['interJinn']['sessionID']

This variable determines the name of the temporary cookie that will be sent to the visitor's browser.

Example:
$GLOBALS['interJinn']['sessionID'] = 'InterJinnSession';

$GLOBALS['interJinn']['sessionDisabled']

A quick way to disable sessions. If this is set to true then session cookies will not be sent to visitors. That said, it is still important to set the other information since sessions will still be created server side. The reason for this is that if sessions were previously activated then it is quite likely that sessions are being used elsewhere in the code and so it is convenient for this to still work despite a cookie not being sent to the visitor.

Example:
$GLOBALS['interJinn']['sessionDisabled'] = false;

$GLOBALS['interJinn']['sessionCleanupOdds']

This determines how often sessions are cleaned. In other words, how often timed out sessions are flushed. Whenever a page is a loaded the session engine chooses a random number between 1 and $GLOBALS['interJinn']['sessionCleanupOdds']. If the chosen random number equals 1 then the sessions are cleaned. If this value is set to zero then timed out sessions will never be flushed. This is very useful if you wish to use an external daemon to perform the cleanup.

Example:
$GLOBALS['interJinn']['cleanupOdds'] = 5000;

$GLOBALS['interJinn']['sessionTimeout']

Set this variable to the number of seconds for which a session should be allowed to live without refresh. If the session is not refreshed for this length of time then it will time out and be flushed the next time the sessions are cleaned. For the most part you want sessions to live long enough for a user to fulfill any forms on your site so that they may successfully submit the form and refresh their session. If you set this to zero then sessions will never timeout.

Example:
$GLOBALS['interJinn']['sessionTimeout'] = 60 * 60 * 2;

$GLOBALS['interJinn']['sessionCompression']

Set this to true to have session data compressed when saved and uncompressed when retrieved. Note you canot cleanly switch between the two without losing the data -- but this is a failry moot point since session data is not supposed to last very long.

Example:
$GLOBALS['interJinn']['sessionCompression'] = true;

$GLOBALS['interJinn']['sessionDatabase']

When this has not been set, then the InterJinn database declaration with the name default is used for all database sessions. The value of this may either be a name of a declared database or an array containing the appropriate database connection parameters as described in the database declaration section.

Example:
$GLOBALS['interJinn']['sessionDatabase'] = 'someOtherDatabase';

$GLOBALS['interJinn']['sessionTablePrefix']

When this has been set, all tables accessed by the session service will be prefixed with the given value. This makes it possible to use InterJinn database page patterns within a pre-existing site that may already use any of the required table names.

Example:
$GLOBALS['interJinn']['sessionTablePrefix'] = 'interjinn_';

Filesystem Based Session System

$GLOBALS['interJinn']['sessionSystem']

Set this to file to enable the file system based session system.

Example:
$GLOBALS['interJinn']['sessionSystem'] = 'file';

$GLOBALS['interJinn']['sessionID']

This variable determines the name of the temporary cookie that will be sent to the visitor's browser.

Example:
$GLOBALS['interJinn']['sessionID'] = 'InterJinnSession';

$GLOBALS['interJinn']['sessionDisabled']

A quick way to disable sessions. If this is set to true then session cookies will not be sent to visitors. That said, it is still important to set the other information since sessions will still be created server side. The reason for this is that if sessions were previously activated then it is quite likely that sessions are being used elsewhere in the code and so it is convenient for this to still work despite a cookie not being sent to the visitor.

Example:
$GLOBALS['interJinn']['sessionDisabled'] = false;

$GLOBALS['interJinn']['sessionCleanupOdds']

This determines how often sessions are cleaned. In other words, how often timed out sessions are flushed. Whenever a page is a loaded the session engine chooses a random number between 1 and $GLOBALS['interJinn']['sessionCleanupOdds']. If the chosen random number equals 1 then the sessions are cleaned. If this value is set to zero then timed out sessions will never be flushed. This is very useful if you wish to use an external daemon to perform the cleanup.

Example:
$GLOBALS['interJinn']['cleanupOdds'] = 5000;

$GLOBALS['interJinn']['sessionTimeout']

Set this variable to the number of seconds for which a session should be allowed to live without refresh. If the session is not refreshed for this length of time then it will time out and be flushed the next time the sessions are cleaned. For the most part you want sessions to live long enough for a user to fulfill any forms on your site so that they may successfully submit the form and refresh their session. If you set this to zero then sessions will never timeout.

Example:
$GLOBALS['interJinn']['sessionTimeout'] = 60 * 60 * 2;

$GLOBALS['interJinn']['sessionDataPath']

This should be set to the root path at which all of your sessiond data should be stored. Make sure that you have the right permissions and ownerships set for the target or you will have problems when the session system attempts to create or access the stored data.

Example:
$GLOBALS['interJinn']['propertyDataPath'] =
    '/var/www/interJinn/data/yourProject/session/';

$GLOBALS['interJinn']['sessionCompression']

Set this to true to have session data compressed when saved and uncompressed when retrieved. Note you canot cleanly switch between the two without losing the data -- but this is a failry moot point since session data is not supposed to last very long.

Example:
$GLOBALS['interJinn']['sessionCompression'] = true;