|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2002-08-20 21:35 UTC] sniper@php.net
[2002-08-20 21:35 UTC] sniper@php.net
[2002-08-21 00:57 UTC] frank at orite dot com
[2002-08-21 01:28 UTC] frank at orite dot com
[2002-09-29 11:16 UTC] iliaa@php.net
[2002-09-29 19:01 UTC] frank at orite dot com
[2002-09-29 19:01 UTC] frank at orite dot com
[2002-09-29 20:01 UTC] sniper@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Nov 07 20:00:01 2025 UTC |
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?