Re: [PHPLIB] Problem with page_close... From: Teodor Cimpoesu (teo <email protected>)
Date: 10/29/99

Andre Eisenbach wrote:
>
> Hi!
>
> I have a page which pretty much looks like this:
>
> page_open("sess"=>"My_Session", "auth"=>"My_Auth");
> << HTML CONTENT >>
> page_close();
>
I think that should be
  page_open(array("sess"=>"My_Session", "auth"=>"My_Auth"));
cause the protoyype is page_open($feature),
hmm and you say that that works?

> Works fine. (Remark: The session and auth info are stored in a MySql
> database called
> "MY_AUTH").
>
> Now I try this:
> page_open("sess"=>"My_Session", "auth"=>"My_Auth");
>
> $data_db = new MY_DATA;
> $data_db->query(...);
>
> << HTML CONTENT >>
> page_close();
>
> Now page_close() gives me an MySql error. Saying that the DATABASE
> "MY_DATA" does not contain a table called "active_sessions". And yes,
> that is true. But I want it to use the active_sessions table in the
> "MY_AUTH" database. And that works fine as long as I don't mention
> MY_DATA anywhere.
> Any clues???
As far as I undestood page_close() will just freeze the session. Now
the session must have a DB configured where to store it's data.
So extend CT_Sql to use your Auth database tables, and provide that
class to session extension class.

e.g.
class AUTH_Sql extends DB_Sql {
    var $classname = 'AUTH_Sql';
    var $Host = MY_HOST;
    var $Database = MY_AUTH;
    var $User = DB_USER;
    var $Password = DB_PASSWD;
}

class AUTH_CT_Sql extends CT_Sql {
  var $classname = 'AUTH_CT_Sql';
  var $database_class = 'AUTH_Sql';
  var $database_table = 'active_sessions';
}

class My_Session extends Session {
  var $classname = 'My_Session';
  var $cookiename = 'Foo_Session';
  var $magic = 'rm -rf /';
  var $mode = 'cookie';
  var $fallback_mode = 'get';
  var $lifetime = 0;
  var $that_class = 'AUTH_CT_Sql';
  var $gc_probability = 10;
...
}
then
page_open(array("sess"=>"My_Session", "auth"=>"My_Auth"));
will use your MY_AUTH database.
I think :)

-- 
CIMPOESU Teodor, Web Programmer

@ DIGICOM S.A. Bucharest, Romania @ Internet, site development @ teo <email protected>,+(401)-330.47.28

official home page ~ http://www.digiro.net/ Internet web page ~ http://internet.digiro.net/ - PHP3 Base Library Mailing List. Send messages to <phplib <email protected>>. To unsubscribe, send "unsubscribe" to <phplib-request <email protected>> in the body, not the subject, of your message.