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: 14 years ago
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!';

?>


For more information send a message to info at phpclasses dot org.