| 
        php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
  [2003-06-18 23:57 UTC] jpenn at cheetah-soft dot com
 Description: ------------ When connecting to the database inside the class object, everything works fine with session_set_save_handler(). But, when connecting outside of the class that holds the methods, php does'nt recognize there is an active connection to the DB. Is this a known problem that I have overlooked in the bug db? I have tried everything, including passing the res id of the connection into the session handler class but to no avail. ~ Thanks PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits             
             | 
    |||||||||||||||||||||||||||||||||||||
            
                 
                Copyright © 2001-2025 The PHP GroupAll rights reserved.  | 
        Last updated: Tue Nov 04 06:00:01 2025 UTC | 
Ok - I thought the first post was clear. When using session_set_save_handler() inside a class when using a DB as the storage medium - you must connect to the DB inside of the open function/method. First, we set the methods to use: session_set_save_handler( array( &$this, 'open' ), array( &$this, 'close' ), array( &$this, 'read' ), array( &$this, 'write' ), array( &$this, 'destroy' ), array( &$this, 'gc' ) ); Now, this is the open method: function open( $blah, $blah ) { $res = mysql_connect( 'blah', 'blah', 'blah' ); mysql_select_db( 'blah', $res ); return( true ); } The above works. When explicitly connecting inside of the open method - everything works like a charm. Now, if you DO NOT EXPLICITLY CONNECT (to the DB) inside of this method - the session handler will not work. This is just not specific to one DB and (or) operating system, it is a problem accross a magnitude of platforms. Is this a scope issue?[quote] As long as you fail to provide a full, but short example script which CLEARLY shows whatta hell you're talking about, this stays bogus. [/quote] What in gods name are you talking about? Do you not see in the 4th post on this bug? That is as clear as it gets. Are you a kid or something sniper? This is rediculous that you are popping in and out of this and totally overlooking the posts on this bug. [From 4th post in this bug] session_set_save_handler( array( &$this, 'open' ), array( &$this, 'close' ), array( &$this, 'read' ), array( &$this, 'write' ), array( &$this, 'destroy' ), array( &$this, 'gc' ) ); Now, this is the open method: function open( $blah, $blah ) { $res = mysql_connect( 'blah', 'blah', 'blah' ); mysql_select_db( 'blah', $res ); return( true ); } -------------------------------------------- Do you not see that? Do you want it emailed to you?