[phplib-dev] custom session save handler From: R.B. Scholtus (regiment <email protected>)
Date: 12/04/00

Hello all,

Ive written a custom session save handler for php4 based on CT_Sql.
With this handler, you can use php4 sessions while saving your session data
in a sql database instead of a file or shared memory.
Writing it was _very_ easy so it will be reliable as soon i take more time
to verify the code and test it.
The handler can be used for sites using php4 sessions and thus also for
sites using the phplib-4 extension.
A working version is http://phplib-4.myip.org/
Installing is (going to be) as easy as extending it in local.inc, similar to
what we do now:
    class Example_Session extends Session {
    ...
      var $that_class = "Example_Sql_Savehandler"; ## name of data
storage container
      var $that_class = "php4 native"; ## example of how it can be done
also. however
    ...
    }
    class Example_Sql_Savehandler extends Sql_Savehandler {
      var $database_class = "DB_Example"; ## Which database to
connect...
      var $database_table = "active_sessions"; ## and find our session data
in this table.
    }
    page_open("sess" => "Example_Session");
I have to integrate it into the phplib-4 extension better.
I suspect it to be faster then the original CT_Sql because it is smaller.
But this is just a minor feature of course.

Writing other session save handlers based on existing CT_* containers should
be_very_ easy too.
The advantage of these ported CT_* save handlers is that they are not
necessarily related to phplib sessions. So they can be used with and without
phplib sessions.

Right now im very busy so i dont have time to test it thoroughly and publish
it on cvs.
I wonder if i should publish it in the phplib cvs anyway, as it is actually
php4 related.

Ive read the email about a new phplib session API.
I like the idea of a nicely structured Session classes framework. I just
doubt the need. We specify containers now with $that_class, we can continue
doing that. Not specifying a $that_class defaults to php4 native sessions
(for example).
Ill try to figure out some ideas about the subject.

Im sorry i dont have time to write more documentation or complete anything
decently, i just wanted to have it up and running now.

Brian

----- Original Message -----
From: Teodor Cimpoesu <teo <email protected>>
To: <phplib-dev <email protected>>
Sent: Monday, December 04, 2000 12:24 PM
Subject: Re: [phplib-dev] Re: [phplib] PHPlib session using PHP4 sessions
implementation: the code

> Hi Max!
> On Mon, 04 Dec 2000, Max Derkachev wrote:
>
> > I doubt. It is only sufficient if you don't want any other storage
besides
> > filesystem and shared memory. For me, the database storage is needed.
> >
> true, I agree on that we should use the already existent container classes
> to ease their use in conjunction with session save handlers.
>
> > Well, phplib-4 is only wrappers to standard php4 session (with standard
session
> > modules). No more no less. I do think that such a module to be a part of
the
> > "PHPLib for PHP4 (C) " :)). It should handle sessions, when standard
storage is
> > sufficient. But I think the goal of the phplib is to make some
complicated
> > tasks simple (always been), and we should provide a good interface for
custom
> > storage of the session data.
> +1 yet again.
>
> > > If the storage is your main concern, then i would like to known why
you
> > > didn't contact me or anyone else on cvs or dev list to offer your help
on
> > > the issue.
> on that, I set watches on session files, and sow no triggers, so I
understand
> you worked on something w/o letting others know.
>
> > > We have 3 'ports' now. It shows great stupidity (and lack of
> > > management) to re-reinvent the wheel and it makes ASP/JSP programmers
laugh.
>
> well, I would say I did my job to avoid this, what did you do?
>
> > > Looks like the stupidity points to me first. 15 minutes after i
published my
> > > solution, it appeared there was a solution already (Theodor, i feel so
> > > stupid, i didnt know....... :-))
> :) well, no problem. Don't take it as I wrote that just to "impose" it as
the
> best solution. I took few hours and wrote it just because there were too
many
> Qs on the php-general about PHPLib session compatibility with PHP4, and
PHP4
> is far better than 3 and it's session management should be exploited to
it's
> powers.
>
> You may note in my cvs commit message and in the patch that I invited
> everybody to talk about it, but it got still rapidly.
>
> > Well, I've done the work :). I've got a cvs account at phplib's
repository, and
> > we should deside how to merge our efforts and not to waste our time in
this
> > flame. I'm ready to commit my patches, so let's deside on a structure of
the
> > new session module and integrate all three into one.
> > I guess some changes ought to be made in a structure of the module to
prevent
> > conflicts - the user should specify if he intend to use standard session
> > storage (Your and Theo's module) or user module (mine). Maybe it should
be
> > cpecified in prepend.php, so the necessary module would be included.
Maybe we
> > should make a basic Session class, and then make extensions to it,
covering
> > standard php4 storage modules and the user module, which uses custom
> > containers.
> I love this approach, yap. Design custom classes, from simple session
> management, with a backward compatible API (as the one in the repository
right
> now), and then extend that class to enhance the functionalities.
>
> The start as I see it is settling on a session class API( a Session
Interface,
> to say so).
>
> -- teodor
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: phplib-dev-unsubscribe <email protected>
> For additional commands, e-mail: phplib-dev-help <email protected>

---------------------------------------------------------------------
To unsubscribe, e-mail: phplib-dev-unsubscribe <email protected>
For additional commands, e-mail: phplib-dev-help <email protected>