This sample code displays a solution to show how to prevent multiple login using same credentials at the same time.
This sample has created based on a Stackoverflow question. Please find more description here.
The Persian(Farsi) description has written as a blog post here.