They did this in China as late as the 1970s (maybe later!) I read an article about a pair of Chinese college students who ADMITTED they had sex. He was put in prison, she committed suicide.
You can't control people having sex, and most governments, even religious ones, have given up trying. If you put everyone in prison who had sex without marriage, or outside of marriage, you couldn't build enough prisons to hold them! We don't even have laws against adultery! Cops and courts have better things to do. You can sue a guy for having sex with your wife, but you can't have him arrested.