Best way to do this

Status
Not open for further replies.

ButtLord420

Please delete my devbest account.
Dec 11, 2010
463
32
So I am making a new script which I plan to sell "per seat" so I want to restrict users from logging in on 2 devices. So if user1 is logged in on one machine they cant sign on to another machine. I was thinking of doing this in php but then if there was a power-outage or similar then users won't be able to access their accounts so what is the best way to do this?

I don't want it to be so users have to log out each time before they close their browser, it should just be close browser and don't worry.
 

Weasel

👄 I'd intercept me
Nov 25, 2011
4,132
2,457
The script is aimed for buisness' and they might be using proxies.
Then what do you want to store to do it different? There is nothing you can't change. The only thing you COULD do that also stays when a browser is closed, is adding the IP to a database, and set a cookie named boughtSeat to true.
 

ButtLord420

Please delete my devbest account.
Dec 11, 2010
463
32
Then what do you want to store to do it different? There is nothing you can't change. The only thing you COULD do that also stays when a browser is closed, is adding the IP to a database, and set a cookie named boughtSeat to true.
User logs in > account get's locked so nobody else get's in.
User logs out/closes browser > account unlocked.

what I mean is if a user forgot to click log out, they wont be locked out.
 

Weasel

👄 I'd intercept me
Nov 25, 2011
4,132
2,457
User logs in > account get's locked so nobody else get's in.
User logs out/closes browser > account unlocked.

what I mean is if a user forgot to click log out, they wont be locked out.
Add a field in the database "locked" with enum('0', '1') being 0 not locked and 1 locked. When a user logs in, locked will be set to 1, when he clicks logout, locked will be set to 0.
 

ButtLord420

Please delete my devbest account.
Dec 11, 2010
463
32
Add a field in the database "locked" with enum('0', '1') being 0 not locked and 1 locked. When a user logs in, locked will be set to 1, when he clicks logout, locked will be set to 0.
So if a user forgot to click on logout, they would be locked out? I'll still do it like this but is there a way I can make it so when they close the browser some javascript or something changes that value? What is there is a power outage and they are locked out?
 

Weasel

👄 I'd intercept me
Nov 25, 2011
4,132
2,457
So if a user forgot to click on logout, they would be locked out? I'll still do it like this but is there a way I can make it so when they close the browser some javascript or something changes that value? What is there is a power outage and they are locked out?
Just let people still can log-on when locked is 1 if there IP equals ip_last in the database.
 

Ecko

23:37 [autobots] -!- eckostylez [[email protected]]
Nov 25, 2012
1,396
960
He doesn't want that... read the thread and his comments.
I've read the entire thread, thanks.

Jamz said:
I don't want it to be so users have to log out each time before they close their browser, it should just be close browser and don't worry.
Hey guess what? Sessions expire when the browser is closed.

User logs in > creates session
User logs in elsewhere > destroys previous session for user and creates new one

I've done this numerous times on multiple platforms.
 

ButtLord420

Please delete my devbest account.
Dec 11, 2010
463
32
I've read the entire thread, thanks.


Hey guess what? Sessions expire when the browser is closed.

User logs in > creates session
User logs in elsewhere > destroys previous session for user and creates new one

I've done this numerous times on multiple platforms.
Thanx Mate,
How would I deny the user from using another session?
 

Markshall

Русский Стандарт
Contributor
Dec 18, 2010
2,637
2,389
Thanx Mate,
How would I deny the user from using another session?
Make a table in your database that stores all online user sessions and it removes them every 5 minutes if the user is inactive. Make your login script check against that table to see if the user is already logged in, if so, tell them to back off.
 

ButtLord420

Please delete my devbest account.
Dec 11, 2010
463
32
Make a table in your database that stores all online user sessions and it removes them every 5 minutes if the user is inactive. Make your login script check against that table to see if the user is already logged in, if so, tell them to back off.
Thanks to you and everyone else who helped in this thread (holmes, eckostylez & habbotard69) Please close thread.
 
Status
Not open for further replies.

Users who are viewing this thread

Top