Subject RE: [firebird-php] Re: Firebird php session handling functions?
Author Alan McDonald
> > On 19-Jun-2006 12:51:38, firebird-php@yahoogroups.com wrote:
> > I am re-visiting this and trying to get php to use firebird for
> > storing php sessions.
> >
> > There are plenty of exmaples of the various php functions required for
> > MySQL but I haven't found anything yet done in Firebird. Anyway, I
> > have created a set of functions i.e. sessionOpen, sessionClose,
> > sessionRead etc.. as best I can, but I don't think I've even got past
> > php recognising the Firebird database and table as the storage as I'm
> > getting the error "Failed to initialize storage module".
> >
> > Firstly, in php.ini, I am wondering how exactly to specify the
> > "session.save_path" and "session.name" configs. Would
> > "/opt/firebird/city/city.fdb" and "tblphpsessions" be valid (e.g. is
> > the .fdb suffix required or not?.
> >
> > There are more questions to follow to get this working I'm sure, but
> > i'll leave it there to see whether anybody has done this successfully
> > or not.
>
> As your request is a little vague, I'm going to make some assumptions, so
> forgive me if I'm wrong on this but at least it will allow you to
> expand on
> your requirements and I'll share how we are doing this sort of thing.
>
> When you say 'Sessions', I'm assuming you are referring to 'Server Side
> Sessions' rather than client sessions. In PHP, a session is typically a
> client side session, that can be pulled from the browser and referenced
> through an array structure. My guess is that you want to use the client
> session ID as a key reference in Firebird for something, and possibly the
> other array elements for something to be persistently stored. The problem
> with this approach is that the client's session expires when they close
> their browser session, etc. So the persistence of this data would have to
> take that into consideration.
>
> What we do with this, which works great, is to use the Session handling of
> PHP in conjunction with a MVC framework. We use Code Igniter
> (www.codeigniter.com) and have modified it to use Firebird as our database
> of choice. We don't use their DB models but use our own.
> However there is
> an extension to CI's session handling, called PHPSession that has much
> richer functionality for this.

you've got me baffled Myles.... what the hell (the website is so broken I
can't make it tell me) does codeigniter do? I can understand the need for a
database class to make working with websites and your favourite scripting
language a little easier but PHP does all the right stuff out of the box. I
just can't see how this stuff can make your work faster or easier....
please please enlighten me - I'm too dumb to see the woods for the trees...
Alan
(PS - it's like some of the CMS fraweworks around... they mature a little
and in so doing they become their own worst enemy as far as just getting a
simple job done in the best time.)


>
> In practice, our use of this is to put a 'user no', for example, in the
> browser session of a client after they authenticate. For each
> page request
> that comes back in from that browser, we check the user no against our
> registered user table. If a user's ability to access the system
> expires, or
> changes, because we use a MVC approach and all incoming requests
> go through
> a Controller in PHP, it's the controller that redirects the user
> out of the
> system and kills their session information in the browser if there is a
> breach of security. Of course, with each web page request coming in from
> anywhere, trying to piece together a flow of page to page action
> from a user
> is hard, but we design our pages to really not require a
> persistent session
> ID to flow from page to page if possible. Every web designer will look at
> this differently, but the one thing is key - the web is not a
> client/server
> application so trying to make it work like one can be fraught with issues.
> However a session in some ways does help to tie things together a bit but
> really shouldn't be used to simulate client/server application behavior.
>
> Therefore if what you want to do is store some small amount of data on the
> client's browser session, but reference it in PHP, then you can do that by
> just getting the session data in an array from PHP and walking through the
> array and storing the content you want in Firebird. Any normal connection
> to FB would be fine for this. You don't need to use any pre-rolled stuff
> for this as its about 8 lines of code and you're done. But if
> you need more
> than this, I guess that's where I'm at a loss as to exactly what you are
> looking to achieve and how to suggest a direction.
>
> As for referencing your FB database in PHP, you need to ensure that you
> include reference to the server & the path for Firebird. For example
> /opt/firebird/databases/mydbase.fdb really should be referenced as
> server:/opt/firebird/databases/mydbase.fdb and yes, the .fdb is
> required.
>
> Hope this helps in some way.
>
> Regards,
> Myles