In Kingdom Hearts 2, DiZ asks Riku if he's remembering now, and Riku replies that "The haze is lifting." I think it would imply that while perhaps Riku did not forget who Sora was, he was beginning to forget certain things. I imagine his presence may have been part of that, but I also imagine that the fact that Sora's memories of Riku were never significantly tampered with might explain why Riku seems to remember Sora with some clarity.