session_set_save_handler and error handling

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Werner Elflein

    session_set_save_handler and error handling

    Let open, close, read, write, destroy and gc be PHP functions to save
    the superglobal array $_SESSION in a database.

    I would like to use the following code:

    [1] session_set_sav e_handler(open, close,read,writ e,gc);
    [2] session_start() ;
    [3] if(!isset($_SES SION))
    [4] {
    /* error handling */
    exit;
    }
    /* session okay */

    But what will happen, if (e.g.) the database is down?
    Means: What kind of error handling can or must be implemented within the
    functions open, close, read, write, destroy and gc to get a stable
    script? Of course, line [3] is not enough ...
  • petersprc

    #2
    Re: session_set_sav e_handler and error handling

    You can trigger a fatal error with trigger_error(' Message',
    E_USER_ERROR) or throw an exception. If your read function fails, that
    should return false.

    On Jul 13, 4:29 pm, Werner Elflein <em...@wernerel flein.dewrote:
    Let open, close, read, write, destroy and gc be PHP functions to save
    the superglobal array $_SESSION in a database.
    >
    I would like to use the following code:
    >
    [1] session_set_sav e_handler(open, close,read,writ e,gc);
    [2] session_start() ;
    [3] if(!isset($_SES SION))
    [4] {
    /* error handling */
    exit;
    }
    /* session okay */
    >
    But what will happen, if (e.g.) the database is down?
    Means: What kind of error handling can or must be implemented within the
    functions open, close, read, write, destroy and gc to get a stable
    script? Of course, line [3] is not enough ...

    Comment

    Working...