Another easy way for me to do it is:
1) Create another field 'IsLogoutProperly' of type boolean with default = false
2) When user logout, set it to true
3) If there's power failure / PC restart, the value will remain false, which
means the user didnt logout properly.
4) So i can use this value to do some verification when user try to login ..
I know probably not a good idea, but it's kinda simple. Or does it has anything
wrong ?
Warrick Wilson <[EMAIL PROTECTED]> wrote:Sorry for top-posting here...
What I'd do is add a timestamp column to your table
called LastActivity. Whenever a user does something,
update the record for that user with the current time.
You can then implement a "timeout" on the session -
e.g. the user walks away from the PC to a meeting and
doesn't log out - so that if there's no activity for
15 minutes (or whatever your default is), then you can
force the logout by deleting the user's record from
the table. You could do the check for abandoned
sessions every time you go to do an update of a
current action.
As someone else mentioned, if your server crashes,
then part of your startup routine for your system
should be to clear out the table. Note that if you
implement the LastActivity, then any power failure
over your default timeout would clear the table for
you first.
--- soonhuat ong <[EMAIL PROTECTED]> wrote:
> Hi,
>
> Thanks for your comments. One more question here,
> when the user logout from the terminal, I'll delete
> it from the ManageUsers table. What about if there's
> an electrical/power failure or other cause ?? That
> particular user record won't deleted, so next time
> when he/she try to login the "Exception
> TooManyLogins" will be executed. Thanks again.
>
> Mick Arundell <[EMAIL PROTECTED]> wrote:
>
> Message: 11
> Date: Tue, 7 Jun 2005 00:40:37 -0700 (PDT)
> From: soonhuat ong <[EMAIL PROTECTED]>
> Subject: Restrict only 1 terminal login for 1 user
>
> Is there any way for me to restrict that one user
> can
> only allow to
> login 1 terminal/PC . Means that if they try to
> login
> to other PC, the
> system will provide them with the message : "Login
> failure". For your
> information, i'm using Interbase 6. Thx
>
> Soonhuat,
> 1) Drop Interbase 6 use Firebird
> 2) I assume you want to limit each user to one
> login
> at a time.
>
> Solution,
> Create table ManageUsers(
> UName char(32),
> constraint ManageUsers_Pk primary key (Uname)
> );
>
> create Exception TooManyLogins 'Only one login at a
> time';
> set term ^ ;
> create trigger ManageUsers_Bi for ManagerUsers
> active
> before insert
> position 0
> as
> begin
> new.UName = Current_User;
> end
>
> set term ; ^
>
> On your datamodule have an sql object with the code
> insert into ManageUsers
> (UName)
> values
> ('user') /* any value here since it will be replaced
> by the trigger*/
>
>
> in your client application have a routine that runs
> after connect
> procedure TDataModule.AfterDbConnect(Sender :
> TObject)
> begin
> with ManageUsersQ do begin
> try
> Transaction.Active := true;
> if not prepared then prepare;
> ExecQuery;
> if Transaction.InTransaction then
> Transaction.Commit;
> ConnectedOk := true;
> except
> on E:Exception do begin
> //only here because user is already logged in
> //message from database suffices
> if Transaction.InTransaction then
> Transaction.RollBack;
> ConnectedOk := false;
> ShowMessage(E.Message);
> Database.Connected := false;
> Close;
>
> end;
> end;
>
>
> end;
> end;
>
> Now all you need is a flag so you can remove the
> token
> in ManageUsers table on clean exit
>
> delete from ManageUsers where
> UName = Database.ConnectParams.UserName;
>
> a better way would be to have a transaction
> dedicated
> to this task and start the transaction OnLogin and
> roll it back OnLogOut;
>
> This way you could do something like
> Update ManageUsers
> set UName = UName
> where UName = UName;
>
> if row is already in update your transaction fails
> otherwise you keep a lock on while user is connected
>
> If your connection fails Firebird will rollback the
> transaction shortly after the connection fails.
> In addition you have a table where you can store
> user
> preferences and states between instances
>
> Mick
>
>
>
> Send instant messages to your online friends
> http://au.messenger.yahoo.com
>
>
>
-----------------------------------------------------
> Home page: http://groups.yahoo.com/group/delphi-en/
> To unsubscribe:
> [EMAIL PROTECTED]
>
>
>
> ---------------------------------
> Yahoo! Groups Links
>
> To visit your group on the web, go to:
> http://groups.yahoo.com/group/delphi-en/
>
> To unsubscribe from this group, send an email to:
> [EMAIL PROTECTED]
>
> Your use of Yahoo! Groups is subject to the
> Yahoo! Terms of Service.
>
>
>
> ---------------------------------
> Discover Yahoo!
> Have fun online with music videos, cool games, IM &
> more. Check it out!
>
> [Non-text portions of this message have been
> removed]
>
>
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
-----------------------------------------------------
Home page: http://groups.yahoo.com/group/delphi-en/
To unsubscribe: [EMAIL PROTECTED]
---------------------------------
Yahoo! Groups Links
To visit your group on the web, go to:
http://groups.yahoo.com/group/delphi-en/
To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
---------------------------------
Discover Yahoo!
Stay in touch with email, IM, photo sharing & more. Check it out!
[Non-text portions of this message have been removed]
-----------------------------------------------------
Home page: http://groups.yahoo.com/group/delphi-en/
To unsubscribe: [EMAIL PROTECTED]
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/delphi-en/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/