note 11268 rejected and deleted from session_set_save_handler by jmcastagnetto
| From: | jmcastagnetto@php.net | Date: | Tue, 13 Feb 2001 17:52:45 +0000 |
| Subject: | note 11268 rejected and deleted from session_set_save_handler by jmcastagnetto | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-11001@lists.php.net to get a copy of this message | ||
Can anybody help me to get this to work, I think I got a long way :-)
-----
<?php
/****************************************
* function open *
****************************************
* Called before every action which *
* handles sessions. *
* Set the DB connection and DB name. *
****************************************/
function open ($save_path, $session_name) {
global $sess_save_path, $sess_session_name, $sess_db_conn;
$sess_session_name = $session_name;
if ($db_conn = @mysql_pconnect ("localhost", "root", "bve_mysql"))
{
if (@mysql_select_db ("BVE_Sessions", $db_conn));
$sess_db_conn = $db_conn;
return (true);
} else {
return (false);
}
}
function close () {
global $sess_save_path, $sess_session_name, $sess_db_conn;
mysql_close ($sess_db_conn);
return (true);
}
function read ($id) {
global $sess_save_path, $sess_session_name, $sess_db_conn;
if ($q_rslt = @mysql_query ("SELECT sessionData FROM Sessions_Data WHERE sessionID =
'$id'", $sess_db_con)) {
$rslt_row = @mysql_fetch_array ($q_rslt);
echo $rslt_row;
return ($rslt_row["sessionData"]);
} else {
return ("");
}
}
function write ($id, $sess_data) {
global $sess_save_path, $sess_session_name, $sess_db_conn;
if ($q_rslt = @mysql_query ("SELECT sessionID FROM Sessions_Data WHERE sessionID =
'$id'")) {
return (@mysql_query ("UPDATE Sessions_Data SET sessionData='$sess_data'
WHERE sessionID='$id'"));
} else {
return (@mysql_query ("INSERT INTO Sessions_Data VALUES ('$id',
'$sess_data')"));
}
}
function destroy ($id) {
global $sess_save_path, $sess_session_name, $sess_db_conn;
return (@mysql_query ("DELETE FROM Sessions_Data WHERE sessionID = '$id'"));
}
/*********************************************
* WARNING - You will need to implement some *
* sort of garbage collection routine here. *
*********************************************/
function gc ($maxlifetime) {
global $sess_save_path, $sess_session_name, $sess_db_conn;
return true;
}
session_set_save_handler ("open", "close", "read", "write",
"destroy", "gc");
/*
Call this file with 'include_once' and
proceed to use sessions normally
*/
?>