<?php
/**
 * The interface for session handlers.
 */
interface session_handler
{
    ////////////////////////////////////////////////////////////////////////////
    // Overload functions.

    ////////////////////////////////////////////////////////////////////////////
    // Interface functions.

    /**
     * Opens a session.
     * 
     * @param string $directory The session directory.
     * @param string $name The session name.
     * @return boolean True if successful, else false.
     */
    public function open($directory, $name);

    /**
     * Closes a session.
     * 
     * @return boolean True if successful, else false.
     */
    public function close();

    /**
     * Reads from a session storage.
     * 
     * @param integer $id The session id.
     * @return array The session data.
     */
    public function read($id);

    /**
     * Writes to a session storage.
     * 
     * @param integer $id The session id.
     * @param array $data The session data.
     * @return boolean True if successful, else false.
     */
    public function write($id, $data);

    /**
     * Destroys a session.
     * 
     * @param integer $id The session id.
     * @return boolean True if successful, else false.
     */
    public function destroy($id);

    /**
     * Clears expired sessions.
     * 
     * @param integer $life The expiration limit.
     * @return boolean True if successful, else false.
     */
    public function clear($life);
}
