Login   Register  
PHP Classes
elePHPant
Icontem

File: testsession.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Jo Giraerts  >  CouchDB Session Handler  >  testsession.php  >  Download  
File: testsession.php
Role: Example script
Content type: text/plain
Description: Example on how to use the class
Class: CouchDB Session Handler
Session handler that stores data in CouchDB
Author: By
Last change:
Date: 4 years ago
Size: 1,175 bytes
 

Contents

Class file image Download
<?php
   
include_once 'config.inc.php';

   
// Session stuff
   
require_once 'couchdb_session_handler.php';
   
ini_set("session.gc_maxlifetime",60*30); # 30 minutes
   //session_set_cookie_params(0,"/",".localdomain",false,true);
   
session_name("testsession");
   
$sessionHandler = new CouchdbSessionHandler($config);
   
session_set_save_handler(array ($sessionHandler,"open"),array
(
$sessionHandler,"close"),array ($sessionHandler,"read"),array
(
$sessionHandler,"write"),array ($sessionHandler,"destroy"),array
(
$sessionHandler,"gc"));
   
session_start();



   echo 
"<b>Before:</b> ".$_SESSION['blah']."<br/>\n";
   
var_dump($_SESSION['blahobject']);
   echo 
"<br/>\n";
   
$_SESSION['blah'] = (isset($_SESSION['blah']) ? $_SESSION['blah']+0);
   
$blahobject = (isset($_SESSION['blahobject']) ? $_SESSION['blahobject'] : new stdclass);
   
$blahobject->name "blahobject test";
   
$blahobject->counter is_numeric($blahobject->counter) ? $blahobject->counter 10;
   
$_SESSION['blahobject'] = $blahobject;

   echo 
"<b>After:</b> ".$_SESSION['blah']."<br/>\n";
   
var_dump($_SESSION['blahobject']);

   
// Testing garbage collection
   // $sessionHandler->gc();
?>