Location: PHPKode > scripts > MySessions > mysessions/usage_example.php
<?php

/**
 * @author João Romão (iceburn.info)
 * @copyright 2008
 */

// Don't forget to include your database connection
$db_link = @mysql_connect('localhost', 'db_username', 'db_password') or die('Could not connect: ' . mysql_error());
           @mysql_select_db('db_name') or die('Could not select database');
 
require('./mysessions.class.php');

$session = new MySessions();
 
/**
 * Always safe to use, but not necessary is the create_table() call.
 * You can use it to create the MySQL table. It must be called before 
 * $session->session_start();
 */
$session->create_table(); 
 
/**
 * Instead of using session_start() you must use the class built in function.
 * Same goes for session_destroy(), use $session->destroy(session_id())
 */
$session->session_start();

/**
 * Debugging
 *
 * Comment and uncomment $_SESSIONS to see stored data
 */
$_SESSION['random']  = rand(1, 999);
$_SESSION['another'] = rand(999, 99999);
 
echo '<pre>', $session->debug(), '</pre >';
?>
Return current item: MySessions