Alexander Chalk, prosecuting, said Rahman was overheard talking through pipes to Hasnath in the next cell, telling him: "When you get released, stay squeaky clean and then you can carry on our work."
Hasnath was arrested riding a bicycle in East India Dock Road, near his home, and arrested under the Terrorism Act after posting material to a YouTube site cross-referenced to his non-alcoholic perfume sales site.
Hossein Zahir, defending, said Hasnath had since been moved to Woodhill prison where he had requested to take part in a de-radicalisation programme.
He said of the prison officer's statement: "He has no recollection of this statement. There is no indication that he agreed to what Mr Rahman said."
Mr Zahir added: "He was a naive young man expressing an under-developed interest in these issues. He is remorseful."
Judge Gerald Gordon said he was concerned that Hasnath had been placed in a cell near Rahman.
He said information about the encounter was "extremely worrying", although it appeared it was Rahman not Hasnath who was talking.
The judge said it was not possible for him to make a judgment about Hasnath's future intentions.