I have a php Warning:
session_set_save_handler() [<a href='function.session-set-save-handler'>function.session-set-save-handler</a>]: Argument 1 is not a valid callback
I have googled and looked in php.net/session and can not resolve the problem.
Would someone be so kind to have a look at my script below and give me an idea what I am doing wrong please.
Many thanks
Barbara
[syntax=php]<? php
$session_host = 'localhost';
$session_dbname = 'sessions';
$session_table = 's';
$session_user = 'session';
$session_pass = 'blah';
$session_db = false;
session_set_save_handler (
array(&$session_i, 'open'),
array(&$session_i, 'close'),
array(&$session_i, 'read'),
array(&$session_i, 'write'),
array(&$session_i, 'destroy'),
array(&$session_i, 'gc')
);
class sess_class {
var $session_limit = 2592000;
function open($path,$name) {
global $session_host,$session_user,$session_pass,$session_db,$session_dbname;
if(!$session_db = mysql_pconnect($session_host,$session_user, $session_pass))
return false;
if(!mysql_select_db($session_dbname,$session_db))
return false;
return true;
}
function close() {
$this->gc(0);
return true;
}
function read($s_id) {
global $session_db;
if(!$q = mysql_query("SELECT ses_value FROM s WHERE ses_id='$s_id'",$session_db))
return '';
if(!$r = mysql_fetch_row($q))
return '';
return $r[0];
}
function write($s_id,$data) {
global $session_db;
if(!$q = mysql_query("REPLACE INTO s (ses_id, ses_time, ses_start, ses_value) VALUES ('$s_id','".time()."', '".time()."', '$data')",$session_db))
return false;
if(!mysql_affected_rows($session_db)>0)
return false;
return true;
}
function destroy($s_id) {
global $session_db;
if(!$q = mysql_query("DELETE FROM s WHERE ses_id='$s_id'",$session_db))
return false;
return true;
}
function gc($life) {
global $session_db;
$life = time()-$this->session_limit;
if(!$q = mysql_query("DELETE FROM s WHERE ses_time < $life",$session_db))
return false;
return true;
}
}
$session_i = new sess_class();
?>[/syntax]
Sessions problem
Moderator: General Moderators