Speed Test    Top 25 Hosts    Hosting Reviews    100 Hosts
GalaxyVisions - Ultimate Web Hosting Solutions

Dedicated servers
& web hosting directory

Advance Search    Dedicated Servers   Company Name   HostMatch
Thank you for visiting this site. If you are looking for web hosting services, you have come to the right place. Please search my database of over 2400 hosting companies.

If you need any help, please email me at terence @ hostpulse.com . I will personally try to reply your email within a day and give you some basic guidelines, negotiate with a few hosts to offer you good pricing or answer any hosting related problems that you may have. 
Cheap Web Hosting ASP & ASP.Net Hosting

Dedicated Server

Windows Server Hosting Ecommerce Hosting PHP Hosting
Linux & Unix Hosting Cold Fusion Hosting South America
Europe Reseller Hosting Managed Hosting
Virtual Private Server Asia Pacific Search by Country

Reference and Manual


Hosting Glossary  PHP  HTML 4.01  CSS 2.0  Core Javascript 1.5  XHTML 1.0

session_set_save_handler

session_set_save_handler

(PHP 4 , PHP 5)

session_set_save_handler --  Sets user-level session storage functions

Description

bool session_set_save_handler ( string open, string close, string read, string write, string destroy, string gc)

session_set_save_handler() sets the user-level session storage functions which are used for storing and retrieving data associated with a session. This is most useful when a storage method other than those supplied by PHP sessions is preferred. i.e. Storing the session data in a local database. Returns TRUE on success or FALSE on failure.

Note: The "write" handler is not executed until after the output stream is closed. Thus, output from debugging statements in the "write" handler will never be seen in the browser. If debugging output is necessary, it is suggested that the debug output be written to a file instead.

The following example provides file based session storage similar to the PHP sessions default save handler files. This example could easily be extended to cover database storage using your favorite PHP supported database engine.

Read function must return string value always to make save handler work as expected. Return empty string if there is no data to read. Return values from other handlers are converted to boolean expression. TRUE for success, FALSE for failure.

Example 1. session_set_save_handler() example

<?php
function open($save_path, $session_name)
{
  global
$sess_save_path, $sess_session_name;
       
  
$sess_save_path = $save_path;
  
$sess_session_name = $session_name;
  return(
true);
}

function
close()
{
  return(
true);
}

function
read($id)
{
  global
$sess_save_path, $sess_session_name;

  
$sess_file = "$sess_save_path/sess_$id";
  if (
$fp = @fopen($sess_file, "r")) {
    
$sess_data = fread($fp, filesize($sess_file));
    return(
$sess_data);
  } else {
    return(
""); // Must return "" here.
  
}

}

function
write($id, $sess_data)
{
  global
$sess_save_path, $sess_session_name;

  
$sess_file = "$sess_save_path/sess_$id";
  if (
$fp = @fopen($sess_file, "w")) {
    return(
fwrite($fp, $sess_data));
  } else {
    return(
false);
  }

}

function
destroy($id)
{
  global
$sess_save_path, $sess_session_name;
       
  
$sess_file = "$sess_save_path/sess_$id";
  return(@
unlink($sess_file));
}

/*********************************************
* WARNING - You will need to implement some *
* sort of garbage collection routine here.  *
*********************************************/
function gc($maxlifetime)
{
  return
true;
}

session_set_save_handler("open", "close", "read", "write", "destroy", "gc");

session_start();

// proceed to use sessions normally

?>

See also the session.save_handler configuration directive.

Web Hosting Showcase
View the web hosting showcase to find more relevant web hosting choice that will guide you in selecting a good web hosting company.
 

GalaxyVisions - Ultimate Web Hosting Solutions Cheap Web Hosting ASP & ASP.Net Hosting Dedicated Servers
Windows 2000 & 2003 Server Hosting Ecommerce Hosting PHP Hosting
Linux & Unix Hosting Cold Fusion Hosting South America
Europe Reseller Hosting Managed Hosting
Virtual Private Server Asia Pacific  

Web Hosting and Development Tools

Network Tools  Download Template  Programming Manuals  Developer Tools

  




Net Host Tools

Feature Host







This site provide free reviews of web hosting services from 100 selected companies. There are over 3000 over website hosting companies on the internet. Please research these domain hosting services carefully before you sign up with any. Read articles on web page hosting, web site hosting, domain names, website speed test, cheap web hosting services, PHP scripts, mysql database, asp hosting and virtual private server to gain a better knowledge on domain hosting and cheap web hosting.



Learn more about us
About HostPulse
Contact Us Terms of Use


©2011
All rights reserved.

Questions? Comments? Get started
Affordable Advertising | Host Login & Register
Submission
Submit a news |
Web Hosting and Development Tools
Network Tools  Download Template  Programming Manuals  Search by Country   Links to other sites