Example #1
0
/**
 * Writes an entire session to the database (internal use only).
 *
 * This function is registered with session_set_save_handler() to support
 * database-backed sessions.
 *
 * This function is an internal function and must not be called directly.
 * Doing so may result in corrupted session data or other unexpected behavior.
 * Session data must always be accessed via the $_SESSION superglobal.
 *
 * @param $sid The session ID of the session to write to.
 * @param $value Session data to write as a serialized string.
 * @return true
 */
function _pantheon_session_write($sid, $value)
{
    $session = \Pantheon_Sessions\Session::get_by_sid($sid);
    if (!$session) {
        $session = \Pantheon_Sessions\Session::create_for_sid($sid);
    }
    $session->set_data($value);
}