John Smith wrote:
I am using a custom Session Handler.
session_set_sav e_handler is working well.
But i want to read the data direct from the database.
My problem:
php don't uses the standard serialize function:
For example:
print_r($_SESSI ON):
Array
(
[var1] => 12345
[var2] => Array
(
[ebene1] => e1
[ebene2] => e2
)
)
print_r($_SESSI ON); :
a:2:{s:4:"var1" ;s:5:"12345";s: 4:"var2";a:2:{s :6:"ebene1";s:2 :"e1";s:6:"eben e2";s:2:"e2"; }}
and the data in the database is:
var1|s:5:"12345 ";var2|a:2:{s:6 :"ebene1";s:2:" e1";s:6:"ebene2 ";s:2:"e2"; }:
Can anybody help me?
Anybody has an idea how to make an array from the database data?
Here are the basics of the functions that I use:
function sess_read($key) {
$query='SELECT value FROM psa_sessions WHERE sesskey=\''.
$key.'\' AND expiry > '.time();
}
function sess_write($key ,$val){
global $SESS_LIFE;
// Calculate the session end time
$expiry=time()+ $SESS_LIFE;
$query='SELECT sesskey FROM psa_sessions WHERE sesskey=\''.
$key.'\'';
// if exists
$query='UPDATE psa_sessions SET expiry='.$expir y.', value=\''.
$val.'\' WHERE sesskey=\''.$ke y.'\' AND expiry > '.time();
// if afected rows > 0
return strlen($val);
// else Session has expired
return FALSE;
// else
$query='INSERT INTO psa_sessions SET sesskey=\''.$ke y.
'\', expiry='.$expir y.', value=\''.$val. '\'';
return strlen($val);
}
session_set_sav e_handler('sess _open','sess_cl ose','sess_read ','sess_write', 'sess_destroy', 'sess_gc');
My handlers are all abstracted for Metabase and specific to a package I
wrote (with a lot of file-logging lines in it), so I think giving you
the entire session handler include file would be more confusing that
helpful.
--
Justin Koivisto -
sp**@koivi.com
PHP POSTERS: Please use comp.lang.php for PHP related questions,
alt.php* groups are not recommended.
SEO Competition League:
http://seo.koivi.com/