CREATE PROCEDURE [dbo].[spSubmitSessionInfo]
	@in_username varchar(50),
	@in_sessionId varchar(50)
AS
BEGIN	
	IF (SELECT COUNT(*) FROM [tblUsersOnline] WHERE [session_number]=@in_sessionId) > 0 
		BEGIN
			UPDATE tblUsersOnline SET 
				[username]=@in_username, 
				[session_timestamp]=CURRENT_TIMESTAMP
			WHERE [session_number]=@in_sessionId;
		END
	ELSE
		BEGIN
			INSERT INTO tblUsersOnline (username,session_number, session_timestamp) 
			VALUES (@in_username, @in_sessionId, CURRENT_TIMESTAMP);
		END
	DELETE FROM tblUsersOnline WHERE DATEDIFF(minute,session_timestamp,CURRENT_TIMESTAMP) > 10;
	SELECT COUNT(*) FROM tblUsersOnline;
END