|
Posted by Chung Leong on 03/14/06 18:52
usenet@shat.net wrote:
> Hi all,
>
> I've created a custom session handler that saves session data to a
> MySQL database. If the database server is down, I'd like to fallback to
> PHP's default session handler (files) until the server comes back up.
>
> After calling session_set_save_handler(), is there a way to tell PHP to
> ignore this setting and revert to temp files for session storage? If I
> try an ini_set on session.save_handler upon detecting that the DB
> server is down, it doesn't work because the session is already active.
>
> Thanks
Try shutting down the session by calling session_write_close() before
you call ini_set(). The update handler on session.save_handler checks
the session status. Resetting the status to inactive should allow you
to have the handler back to "files."
I wonder how well such a fallback mechanism would work. Active sessions
at the moment when the database goes down would be lost. The same thing
would happen when the database comes back online as the session files
are now ignored.
Navigation:
[Reply to this message]
|