Welcome Guest, Not a member yet? Register   Sign In
only one login allowed at a time
#1
Question 

i want to control my users.

so i want to ALLOW only one login allowed at a time per userid.

any body help me about this.
Reply
#2

You will find the same question (+ answers) here:
http://stackoverflow.com/questions/30013...er-user-id
Reply
#3

(06-25-2015, 08:20 AM)prodip56 Wrote: i want to control my users.

so i want to ALLOW only one login allowed at a time per userid.

any body help me about this.

You would use a database for your sessions, and add a session ID to your users table. When a user logs in, you add the session ID to the user. When they log out, you delete the session and the user ID in the user record. It's a little more complicated than that, but that's the general idea.
Reply
#4

(06-25-2015, 03:14 PM)skunkbad Wrote:
(06-25-2015, 08:20 AM)prodip56 Wrote: i want to control my users.

so i want to ALLOW only one login allowed at a time per userid.

any body help me about this.

You would use a database for your sessions, and add a session ID to your users table. When a user logs in, you add the session ID to the user. When they log out, you delete the session and the user ID in the user record. It's a little more complicated than that, but that's the general idea.

Problem is: what to do when a user forgets to log out? When he comes back next time, he won't be able to log in.
Reply
#5

In my opinion, it would be easier to logout the first user when someone logs in with the same user credentials. You can do this by checking the session id on every page load with the latest session id in the database.
Reply
#6

(06-26-2015, 01:18 PM)codeIgniter2015 Wrote: In my opinion, it would be easier to logout the first user when someone logs in with the same user credentials. You can do this by checking the session id on every page load with the latest session id in the database.

I agree. But it means that the second user's login must destroy the first user's session. How do you do that?
Reply
#7

(06-27-2015, 01:18 AM)Wouter60 Wrote:
(06-26-2015, 01:18 PM)codeIgniter2015 Wrote: In my opinion, it would be easier to logout the first user when someone logs in with the same user credentials. You can do this by checking the session id on every page load with the latest session id in the database.

I agree. But it means that the second user's login must destroy the first user's session. How do you do that?
go here application/config
1) Find and open config.php and change the value 'sess_expiration' under Session Variable to your desire value(default is 7200).
KeepĀ calm.
Reply
#8

(06-25-2015, 10:31 PM)Wouter60 Wrote:
(06-25-2015, 03:14 PM)skunkbad Wrote:
(06-25-2015, 08:20 AM)prodip56 Wrote: i want to control my users.

so i want to ALLOW only one login allowed at a time per userid.

any body help me about this.

You would use a database for your sessions, and add a session ID to your users table. When a user logs in, you add the session ID to the user. When they log out, you delete the session and the user ID in the user record. It's a little more complicated than that, but that's the general idea.

Problem is: what to do when a user forgets to log out? When he comes back next time, he won't be able to log in.

No, that's not the reason for deleting the session ID from the user's record. It's just that by doing so, you prevent anyone that might have hijacked the user's cookie from using it to be logged in. Your user would absolutely be able to log in again.

I am the author of Community Auth, and have experience with all of this. Using Community Auth or one of the other CI auths has the benefit of all of these little things being worked out, and a whole lot more. Unless you're specifically trying to create your own authentication system just for the experience, you're way better off just using mine or Ion Auth or maybe Flexi Auth (which is based on Ion Auth).
Reply




Theme © iAndrew 2016 - Forum software by © MyBB