Setting up a membership scheme to enrollment of a course

Hi!

I would like to setup a membership scheme to a course. For example once the user purchased a course his enrollment runs only for 3 months.

How to setup this?