#19004 [Opn->NoF]: Can't register session variable by user-level session storage functions
| From: | iliaa@php.net | Date: | Sun, 29 Sep 2002 16:16:00 +0000 |
| Subject: | #19004 [Opn->NoF]: Can't register session variable by user-level session storage functions | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-20676@lists.php.net to get a copy of this message | ||
ID: 19004
Updated by: iliaa@php.net
Reported By: frank@orite.com
-Status: Open
+Status: No Feedback
Bug Type: Session related
Operating System: Windows, IIS
PHP Version: 4.2.2
New Comment:
Please try using this CVS snapshot:
http://snaps.php.net/php4-latest.tar.gz
For Windows:
http://snaps.php.net/win32/php4-win32-latest.zip
Previous Comments:
------------------------------------------------------------------------
[2002-08-21 01:28:00] frank@orite.com
I've tried http://snaps.php.net/win32/php4-win32-latest.zip
just now,
this problem persists.
------------------------------------------------------------------------
[2002-08-21 00:57:23] frank@orite.com
sorry, that was a typo, I actually mean I didn't. From the abstract of
my settings listed that's Off indeed.
------------------------------------------------------------------------
[2002-08-20 21:35:53] sniper@php.net
And btw: We do NOT recommend to turn register_globals=on...
------------------------------------------------------------------------
[2002-08-20 21:35:19] sniper@php.net
Please try using this CVS snapshot:
http://snaps.php.net/php4-latest.tar.gz
For Windows:
http://snaps.php.net/win32/php4-win32-latest.zip
------------------------------------------------------------------------
[2002-08-20 18:41:13] frank@orite.com
register_globals = Off
[Session]
session.save_handler = user
session.save_path = /tmp
session.use_cookies = 1
session.name = PHPSESSID
session.auto_start = 0
session.cookie_lifetime = 0
session.cookie_path = /
session.cookie_domain =
session.serialize_handler = php
session.gc_probability = 1
session.gc_maxlifetime = 1440
session.referer_check =
session.entropy_length = 0
session.entropy_file =
;session.entropy_length = 16
;session.entropy_file = /dev/urandom
session.cache_limiter = nocache
session.cache_expire = 180
session.use_trans_sid = 1
url_rewriter.tags =
"a=href,area=href,frame=src,input=src,form=fakeentry"
I'm trying to use my own session handle functions, which basically
stores information into mysql database. Since I did turn on
register_globals as recommended, I have to use $_SESSION["foo"]="bar"
to register a session variable. The session starts and reads soundly,
but it never registers the variable in this way, seems the write
function hasn't been called when we declare $_SESSION["foo"]="bar".
However if we force a session_register(), the variable can be written
and read on the following pages by accessing the variable $_SESSION.
Note: when I'm on session.save_handler = files, $_SESSION["foo"]="bar"
will simply register the varible to the session file stored.
Here's a paste of my handler functions:
function myopen ($mys_table, $mys_name) {
global $mysession;
$mysession['table'] = $mys_table;
$mysession['name'] = $mys_name;
return true;
}
function myclose() {
global $mysession;
unset($mysession);
return true;
}
function myread ($id) {
global $mysession;
$sql="SELECT data FROM ".$mysession['table']." WHERE
sid='".$id."'";
$result=@mysql_query($sql);
$data=@mysql_result($result,0,"data");
if (strlen($data)>0) {
$la=time();
$sql="UPDATE ".$mysession['table']."SET
lastact='".$la."' WHERE
sid='".$id."'";
}
return $data;
}
function mywrite ($id, $data) {
global $mysession;
echo "write".$data."<br>";
//destory history data before write
$dsql="DELETE FROM ".$mysession['table']." WHERE
sid='".$id."'";
@mysql_query($dsql);
//write new data
$la=time();
$wsql="INSERT INTO ".$mysession['table']." (sid,data,lastact) VALUES
('".$id."','".addslashes($data)."','".$la."')";
@mysql_query($wsql);
return true;
}
function mydestroy ($id) {
global $mysession;
$sql="DELETE FROM ".$mysession['table']." WHERE
sid='".$id."'";
$result=@mysql_query($sql);
return true;
}
function mygc ($maxlifetime) {
global $mysession;
$limitime=time()-$maxlifetime;
$sql="DELETE FROM ".$mysession['table']." WHERE
lastact<'".$limitime."'";
@mysql_query($sql);
return true;
}
//save_path is the SQL table name
session_save_path("mysession");
//customize the session handler
session_set_save_handler ("myopen", "myclose", "myread",
"mywrite",
"mydestroy", "mygc");
//session start
session_start();
Has anyone got a solution to this problem, I mean if there's an
alternative way of coding the handle function for this issue. Or this
is simply a php bug?
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=19004&edit=1