PhpDig.net

What is PhpDig?
PhpDig is a PHP MySQL based
Web Spider & Search Engine.




session_set_save_handler

Name

session_set_save_handler — Sets handlers for custom session functions.

Synopsis

bool session_set_save_handler(open, close, read, write, destroy, gc);
string open: Session init function
string close: Session shutdown function
string read: Session read function
string write: Session write function
string destroy: Destroy session function
string gc: Garbage collection function

Returns

TRUE on success; FALSE on error

Description

This function takes six arguments that descibe the functions used when creating your own session-handling functions. Each function can have any name, but the names must be passed in the correct order. In addition, each function must return the correct information. Using this function, it's possible to write any session handler that you want, including those that store their information in a database, text files, DBM files, or shared memory.

bool open(stringSave path, stringSession name);
Executed when a session is initialized; can be used for
various functions such as initializing variables. The save path and session
name can come from the PHP ini file or via the
 session_save_path()  and
 session_name()  functions. Should return TRUE on success,
FALSE on error.


bool close();
 Executed on shutdown of a session. Can be used to free
memory or to destroy variables. Should return TRUE on success, FALSE on
error.


mixed read(stringSession ID);
Called whenever a session is started. If called with a
session ID, the data associated with that session ID must be read and returned
as a serialized string. If no session ID is passed, an empty string is
returned. Should return FALSE on error.


bool write(stringSession ID, string Value);
Updates or adds new session data. The data to be written must
be serialized. Should return TRUE on success, FALSE on
error.


bool destroy(stringSession ID);
Removes any session data from the data store. Must return
TRUE on success, FALSE on error.


bool gc(stringMax lifetime);
Called at session startup. Designed to remove any sessions
with a lifetime greater than the maximum. Should return TRUE on success, FALSE
on failure.


Version

Existing since version 4.0

Example

Example 1166. Create new session handler

session_set_save_handler("user_open","user_close","user_read","user_write","user_destroy","user_gc")



PHP Functions Essential Reference. Copyright © 2002 by New Riders Publishing (Authors: Zak Greant, Graeme Merrall, Torben Wilson, Brett Michlitsch). This material may be distributed only subject to the terms and conditions set forth in the Open Publication License, v1.0 or later (the latest version is presently available at http://www.opencontent.org/openpub/). The authors of this book have elected not to choose any options under the OPL. This online book was obtained from http://www.fooassociates.com/phpfer/ and is designed to provide information about the PHP programming language, focusing on PHP version 4.0.4 for the most part. The information is provided on an as-is basis, and no warranty or fitness is implied. All persons and entities shall have neither liability nor responsibility to any person or entity with respect to any loss or damage arising from the information contained in this book.

Powered by: vBulletin Version 3.0.7
Copyright ©2000 - 2005, Jelsoft Enterprises Ltd.
Copyright © 2001 - 2005, ThinkDing LLC. All Rights Reserved.