Question

is the a way to stop multi-logins to a website to 1 connection/IP ?

let say that my website is http://website.com and i want only 1 user to browse from 1 IP !

is this possible using php, javascript or htaccess ?

i've done many test to htaccess but all failed

thanks in advance

Was it helpful?

Solution

Yes, but you shouldn't!

Assuming you just want to stop multiple users on one IP address from logging into a typical authentication system, just add two rows to your users database table: last_ip and last_seen.

last_ip is updated on each page load if the user's IP address has changed. last_seen is updated on each page load.

When a user submits a login request, check if another user's last_ip is equal to the user's IP address and last_seen is within a sane time period (say 30 minutes). If so, deny the login request.

It's a bad idea because it's easily avoided

Using a VPN, TOR or an open proxy, it's very easy for users to operate multiple IP addresses in different browsers or even in different tabs in the same browser.

Also, looking forward to IPv6, it's likely that each user will have 64-256 IP addresses by standard.

It's also a bad idea because it harms legitimate users

Users in poor countries, multiple people living in the same home, people at colleges or workplaces may well share IPs. A user does not map well to an IP address.

OTHER TIPS

Yes it's possible but it's a bit weird :) You can save sessions (which also hold the IP address) to the DB, whenever a session is closed/expired - delete it.

If you're using Codeigniter read this.
Otherwise, here's a nice "walk-through".

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top