Hi, Wednesday, January 22, 2003, 6:15:36 PM, you wrote: HJ> Hello, there.
HJ> I'm Looking for 'Mohawk Software session handler functions' examples. HJ> PHP Manual describes it http://www.php.net/manual/en/ref.msession.php . HJ> But, There are no descriptions and examples. HJ> Anybody has one? HJ> Thanks in advanced answer! HJ> ########################## HJ> Heo, Jungsu Mr. HJ> SimpleX Internet. http://www.simplexi.com here is a class I made for msession it may give you some pointers :) <?php class msession_class{ var $ses; //session on flag var $sessionname; //current name of session var $message; //error message holder var $modulename; //type of module, should be user var $sessionid; // var $sessionlife; //how long inactive before the session should time out var $host; //client host var $Username; //username function msession_class($sessionname="",$lifetime="",$maxgc="",$sessionid=''){ global $class_ref; //a reference array for access by buried functions $class_ref["msession_class"] =& $this; ini_set( "session.save_handler", "user" ); function open($save_path, $session_name) { return msession_connect('localhost','8086'); } function close() { msession_disconnect(); return true; } function read($key) { $sessiondata = ""; //This bit won't work on standard msession install it checks for a timed out session //$x = msession_ctl($key,'TTL'); //if(!empty($x) && $x < 0): // msession_destroy($key); //else: $sessiondata = msession_get_data($key); //endif; return $sessiondata; } function write($key, $val) { global $class_ref; msession_set_data($key,$val); msession_timeout($key, $class_ref['msession_class']->sessionlife); return true; } function destroy($key) { global $class_ref; $result = msession_destroy($key); $class_ref["msession_class"]->ses = 0; $class_ref["msession_class"]->sessionid = ""; return $result; } function gc($maxlifetime) { return true; } session_set_save_handler("open", "close", "read", "write", "destroy", "gc"); //set up some defaults $this->sessionname = $sessionname; $this->sessionlife = $lifetime; if($this->sessionname == ""): $this->sessionname = "PHPSESSID"; endif; session_name($this->sessionname); if($lifetime == ""): $this->sessionlife = get_cfg_var("session.gc_maxlifetime"); endif; if(!empty($sessionid)){ session_id($sessionid); } //ok go for it session_start(); $this->modulename = session_module_name(); $this->sessionid = session_id(); $this->ses = 1; } //oddball functions function session_restart(){ session_destroy(); $url = "http://".$_SERVER["HTTP_HOST"];//.$_SERVER["PHP_SELF"]; header("Location: $url"); exit; } function addmessage($mess){ $this->message .= $mess; } function getmessage(){ return $this->message; } function getmodulename(){ return $this->modulename; } function getid(){ return $this->sessionid; } function getlifetime(){ return $this->sessionlife; } function setuser($host,$user){ $this->host = $host; $this->Username = $user; } function getuser($type = ""){ if($type == "u"): return $this->Username; elseif($type == "h"): return $this->host; else: return $this->host." ".$this->Username; endif; } } ?> usage <? include_once('msession_class.inc'); $ms = new msession_class('TESTSESSION'); ..thats it if you want to force it to use the same session from another server/domain with session_id set to the session you want start like this: include_once('msession_class.inc'); $sessionid = ''; if(isset($_REQUEST['session_id'])){ $sessionid = $_REQUEST['session_id']; } $ms = new msession_class('TESTSESSION','','',$sessionid); -- regards, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php