On Tue, 11 Feb 2003, Robin Mordasiewicz wrote:

> Is there a way to configure php to use a database for sessions rather than
> a text file.
> I have a server farm and want the session files to be accessible to all
> machines in the cluster. I can have the session file on nfs but I am
> worried  about file locking.
> I have read tutorials on how to set session.save_handler = user and then
> each script configures their seesion variables and connections, but I
> want this to be transparant to my users. I do not want users to have to
> change anything in their scripts.

Consider this (Warning: I haven't tried this, yet):

Write your session handling functions and put them in a file ... say,
/var/www/server/custom_session.php.  Call session_set_save_handler() with
your function names as arguments in that file.
(Good explanations here:
 http://www.php.net/manual/en/function.session-set-save-handler.php)

In your php.ini file, set:
session.save_handler = user
auto_prepend_file = /var/www/server/custom_session.php

This will cause PHP to use your custom session handler system-wide,
while remaining transparent to your users, I believe.  (If anyone knows
this to be not the case, let me know.)

Caveats:

You'd have to make sure you custom handler function names are unique
enough so as to not conflict with functions names your users can create.

I'm not sure what will happen if your users call
session_set_save_handeler() again, but with their own functions as
handlers.

If after some consideration it still seems like a workable solution and
you try it, let us know how it pans out!

        g.luck,
        ~Chris




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to