Session module

Module for handling sessions

Overview

The session module provides you with an easy way to deal with sessions. PHP offers a really ugly session API, mixing both functions and global variables. Anewt offers a consistent, small wrapper API that hides the internal details and automates some boring (and sometimes subtly annoying) details through the AnewtSession class, which only provides static methods. This means you cannot create session objects by using the new operator, since only one session can be used at any time.

The API is quite simple and resembles the API offered by the AnewtContainer class, but a bit simpler. This simple code snippet illustrates how to use sessions:

Example 1: Using a session

/* Start a new session, eg. after a succesful login attempt */
AnewtSession::init('yourapp');
 
/* Store some data in the session */
AnewtSession::set('username', $username);
 
/* Destroy the session, eg. on logout */
AnewtSession::destroy();

Class listing

This module provides the following classes:

  1. AnewtSession