Login   Register  
PHP Classes
elePHPant
Icontem

File: db_sample.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  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: 2006-02-05 08:46
Size: 703 bytes
 

Contents

Class file image Download
<?php

  
// 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.
  
$ps->install_table();

  
// Set up session handlers.
  
$ps->set_handler();

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

?>