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;
/********************************************* * WARNING - You will need to implement some * * sort of garbage collection routine here. * *********************************************/ function gc($maxlifetime) { return true; }
session set save handler php code on this is provided for your study purpose, it will guide you to know how create and design a website using php. use it to practice and train your self online
Php session set save handler syntax tutorial
php tutorial guide and code design are for easy learning and programming. The code practice section provided at the top is for practising of this syntax. Use the code section up to practice your php programming online. Learning php is very easy, all you need is to use the examples on this site and practice them to perfect your skills.