Jump to content

Ideas for multi-user project


misc

Recommended Posts

Hi everyone,

 

i'm having my project already set up, but i was thinking about the following.

 

I want the a user-lock on login, that means, if a user is already logged in to the user-area or the user is logging in new, i dont want the same user to have another session.

 

My idea is to add a field ('loggedIn') in my user-table of my database which i then use for the lock. BUT what if the session gets killed or the users database connection breaks up. Then i have a logged user which cant log in anymore.

 

How do you handle this or whats your idea?

 

Thanks

Link to comment
Share on other sites

Hi Michael,

 

Try this :

1. Get the number of connexion (let say Nc) after the user log,

2. Accept him without condition (insert his name,... in the table even if he exist),

3. Now Get the number of row of your users Table (let say Nr) after inserting,

4. if Nc = Nr then apply your classical access procedure and delete the double row,

if Nc < Nr that means a Crash system (session killed or internet connexion losted)

Then

Accept the user, even if his name already exist in your login table and delete the double row

 

Conclusion:

This two nubers Nc and Nr are usefull for knowing a crash systeme :

If NC = Nr : All is Ok

If NC < Nr : crash sytem

If NC > Nr : case can't appears

 

best regars

Link to comment
Share on other sites

Hi Abaksoft,

 

thanks for your idea, i like it but i have one scenario that could break up the idea:

For example, if the system crashes, the i have more numbers in the table as connection count, so i know, the system

of one user has crashed. The problem is i dont know which users system, what if one users system crashes and the others is working fine

and another is trying to log in a second time.

 

cheers

Link to comment
Share on other sites

Yes, let see an example :

 

Step 1 :

Assume we have 3 users well connected. The table appears like this :

 

1 James

2 Rodriguez

3 Stephano

 

Here NC = Nr = 3 : All is OK

 

Step 2 :

James Crashs. At this time, we can't know wich users crashes. You are right !

But when james will attempt to re-log again, the problem is solved :

The rule requires an insertion (without conditions)

 

1 James

2 Rodriguez

3 Stephano

4 James

 

At this time your login procedure know that a crash happened : NC=3 < Nr=4 and it's James.

 

Step 3 :

The rule requires to clean the garbage lignes (delete the fist James) :

 

2 Rodriguez

3 Stephano

4 James

 

And all will become OK (NC = Nr).

 

Conclusion :

- a table snapshot view, can't inform us who are well connected.

- but, after each login the problem is solved (the table will be always clean).

 

All the Best.

Link to comment
Share on other sites

Yes, let see an example :

 

Step 1 :

Assume we have 3 users well connected. The table appears like this :

 

1 James

2 Rodriguez

3 Stephano

 

Here NC = Nr = 3 : All is OK

 

Step 2 :

James Crashs. At this time, we can't know wich users crashes. You are right !

But when james will attempt to re-log again, the problem is solved :

The rule requires an insertion (without conditions)

 

1 James

2 Rodriguez

3 Stephano

4 James

 

At this time your login procedure know that a crash happened : NC=3 < Nr=4 and it's James.

 

Step 3 :

The rule requires to clean the garbage lignes (delete the fist James) :

 

2 Rodriguez

3 Stephano

4 James

 

And all will become OK (NC = Nr).

 

Conclusion :

- a table snapshot view, can't inform us who are well connected.

- but, after each login the problem is solved (the table will be always clean).

 

All the Best.

cmiiw:

There's a problem in step 2, but I don't have the answer to solve the problem. :)

 

Step 2 :

James Crashs. At this time, we can't know wich users crashes. You are right !

But when james will attempt to re-log again, the problem is solved :

The rule requires an insertion (without conditions)

 

what if Rodriguez crashes not James and then James attempt to login to have another session?

Link to comment
Share on other sites

Hi everyone,

 

i'm having my project already set up, but i was thinking about the following.

 

I want the a user-lock on login, that means, if a user is already logged in to the user-area or the user is logging in new, i dont want the same user to have another session.

 

My idea is to add a field ('loggedIn') in my user-table of my database which i then use for the lock. BUT what if the session gets killed or the users database connection breaks up. Then i have a logged user which cant log in anymore.

 

How do you handle this or whats your idea?

 

Thanks

Sorry for my english.

 

This is my idea but I don't if it is applicable.

 

the user-table have 2 fields : UserID, DateTime1

 

The client side for suppose every 1 minute update the DateTime1

 according to the server  computer system  time. ( can we get the server side system date/time ?  :) )

 

If the user attemps to re-log again, server will check the difference between sytem time and DateTime1, if the difference is more than 1 minutes than we can assume that the user session has crashed and is allowed to login in again.

  • Upvote 1
Link to comment
Share on other sites

Hi Hendra,

 

"what if Rodriguez crashes not James and then James attempt to login to have another session?"

 

Bingo ! You are right.

My method crashs !

 

Your idea is very nice, and will works fine.

To get the server side systeme date /Time :

If you are working with Firebird, then use the usefull query :

 

Select current_Date, current_Time from Rdb$DataBase

 

For further information, ask who are developping web forum application (like this one),

to get the right method.

 

Best Regards

Link to comment
Share on other sites

×
×
  • Create New...