Have ever wondering on how can you handle a Single Login Per User on your website? Yes may be you will need to disable multiple login due to some security reasons. So here is the only perfect way that you can do it:
When the user login flag on the database either an IP(for single login on a network) or Session Id of the user (for single login across all network).
Then every time the user visit a page in your website check if the flag has been change.
If the flag has been change then log off the current user
That way you can manage only one login per account depending on what situation you want it to happen. If you are thinking that you don’t want to logoff the current user but disable other login that will be impossible to happen. Because you can’t stop a user from closing the browser or shutting down the computer. In such cases you can’t handle on your script.
The said code will give you the full url path to which your user came from.
Example is http://google.com/?some-strings=goes-here
So you can check if its from a user from a google with a particular search string.
Just a Note. It can also received the same domain to which your site is in. For an instance your domain is http://domain.com then you referesh the page, the said code will return http://domain.com because you just refresh the page.