added validation and fixed register session  bug.