Re: database-based sessions for 3rd party php app [message #179020 is a reply to message #179017] |
Wed, 05 September 2012 12:26 |
Erwin Moller
Messages: 228 Registered: September 2010
Karma:
|
Senior Member |
|
|
On 9/5/2012 1:37 PM, The Natural Philosopher wrote:
> Axel wrote:
>> Hi readers,
>> I am currently trying to increase the performance of a 3rd party
>> learning platform web app we are (still) using. The current setup is
>> to store the PHP sessions on an NFS share, which I personally find
>> not-so-good.
>>
>> Now I don't want to touch the code of this app, for various reasons.
>> But I want database sessions.
>> Is there a good, proven and solid way to move the session management
>> to the database _without_ modyfying the app's code?
>>
>>
>
> How could there be?
>
> In order to write something into a *database* in preference to a file or
> directory, requires application level changes. Or an entire rewrite of
> part of PHP.
>
>
No, not in this case, TNP, at least it won't be anything rigorous.
Session handling can be changed for an existing application without
breaking it.
You have to do the following:
1) Change for this application the session storage
session_set_save_handler will take care of that.
The easiest way to do this is by adding a file of yourself somewhere
where you define the settings and call session_set_save_handler.
Maybe the existing application has a file that is included everywhere
(which is very common), then simply add you file to it (via another
include, use full path to your session-definition-file to avoid
complexities with include from other directories)
2) Write the appropriate functions you name in the above function
3) Of course, add a table to the database for storage.
There are a few examples on the net to be found to do this.
If memory serves me well, adodb abstraction layer has one ready-to-go
build in.
From the application point-of-view, there will be no change.
Good luck,
Erwin Moller
--
"That which can be asserted without evidence, can be dismissed without
evidence."
-- Christopher Hitchens
|
|
|