DROP PROCEDURE IF EXISTS `check_if_user_is_logged_in`;
DELIMITER ;;
CREATE PROCEDURE `check_if_user_is_logged_in` (
    IN p_session_id CHAR(64),
    OUT p_return INT
)
proc:BEGIN
    IF (SELECT COUNT(session_id) FROM sessions WHERE session_id = p_session_id) = 0 OR p_session_id IS NULL THEN
        SET p_return = -1;
        LEAVE proc;
    END IF;
    SET p_return = 0;
END ;;
DELIMITER ;
