DROP PROCEDURE IF EXISTS `get_user_from_session`;
DELIMITER ;;
CREATE PROCEDURE `get_user_from_session` (
    IN p_session_id CHAR(64),
    OUT p_return INT
)
proc:BEGIN
    DECLARE v_ret INT;
    CALL check_if_user_is_logged_in(p_session_id, v_ret);
    IF v_ret != 0 THEN
        SET p_return = -1;
        LEAVE proc;
    END IF;
    SELECT user_id INTO p_return FROM sessions WHERE session_id = p_session_id;
END ;;
DELIMITER ;
