In the study of John, Pastor Armstrong states that the reason Jesus did not want Mary Magdalene to cling to Him was because He needed to be untouched before ascending to heaven to cleanse the temple. What then is the explanation for Matthew 28:9, where both Marys are said to "take hold of His feet and worshiped Him"? Is this a different encounter?
The four Gospels are complimentary in their testimony, but they are not identical in their content nor in their chronology. In this case, Matthew is describing a moment that John doesn’t record, a moment that takes place after the one recorded in John 20.
For a brief answer, we need to first understand that the first sin was committed by Satan, who was the covering cherub of the Heavenly Tabernacle. When he fell, he brought sin into the holy of holies. And only Christ's blood could cleanse it. In the earthly tabernacle, the High Priest would enter once a year to cleanse it. On that day, no one was allowed to touch the High Priest until he had completed that work. So here Jesus tells Mary she is not permitted to touch Him – as He is our High Priest – because He had yet to ascend to the Father and complete His atoning work.
Notice, Jesus tells Mary to report back to the brethren that He has ascended to the Father. Only after completing this work of cleansing the Heavenly tabernacle with His own physical blood, Jesus returns to make further appearances to the Disciples. And in those later visits, the disciples are permitted to touch Jesus, as Thomas does eight days after Jesus’ resurrection.
For a full explanation please listen to Lesson 20 of the Gospel of John.