PHP Classes

File: db_sample.php

Recommend this page to a friend!
  Classes of Vagharshak Tozalakyan   Private Sessions   db_sample.php   Download  
File: db_sample.php
Role: Example script
Content type: text/plain
Description: Sample
Class: Private Sessions
Store sessions in a private directory or database
Author: By
Last change:
Date: 17 years ago
Size: 703 bytes


Class file image Download

// Include the class source.
require_once 'private_sessions.class.php';

// Create an object.
$ps = new private_sessions();

// Store session data in MySQL database.
$ps->save_to_db = true;

// MySQL access parameters.
$ps->db_host = 'localhost';
$ps->db_uname = 'root';
$ps->db_passwd = '';
$ps->db_name = 'test';

// The name of the table used to save session data.
$ps->save_table = 'mysessions';

// Optionally create the table if not created.

// Set up session handlers.

// That's all! Proceed to use sessions normally.
$_SESSION['foo'] = 'Hi there!';