CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    May 2005
    Posts
    26

    Allowed No. of Sessions for User

    Hi Every body,

    I have an application programmed with VB 6.0 and I make this application in shared folder so that the others can run it through the network. The application has a list of specified users & their info which stored on a Table in the application's Database. One of the fields of this table called Status, and is YES/NO field. If value of this field is YES that is mean the user currently logged in to application. The purpose of this field is to prevent users from opening more than one session on different PCs.
    Some times a Network's problem happens then the user will be disconnected but because the application terminated abnormally the state of this user still CONNECTED (YES). So the user can't login again till I reset its state from DB file & changed from YES to NO.

    Is there any ideas to restrict the user with one session only?

    Thanks in advance.

  2. #2
    Join Date
    Jul 2006
    Location
    Germany
    Posts
    3,725

    Re: Allowed No. of Sessions for User

    Hi, and welcome.
    A dynamic solution would be good here.
    Your application could use a timer that comes up in intervals of, say, 2 seconds, looks if the field is YES. If it is NO it sets it back to YES.
    A small program started in that folder runs permanently and sets all the users fields which are YES to NO, say every 20 seconds (I don't know about the exact timing, one could play with it.)
    So most of the time the field is YES and a double login would be very impropable, but 20 seconds after a program crash, the field becomes NO and the user can login again.

  3. #3
    Join Date
    May 2005
    Posts
    26

    Re: Allowed No. of Sessions for User

    Thanks WoF, but I'm sorry I couldn't understand your idea. Could you please demonestrate more?

  4. #4
    Join Date
    Nov 2004
    Location
    Lincoln, NE
    Posts
    516

    Re: Allowed No. of Sessions for User

    The best solution I can think of is to make a key authentication system instead of a state based system. Instead of attempting to stop users from opening a new instance, just stop them from using any older instances. I would do something like this.

    When the user opens the application, it would write the username, a unique identifier (like the network address or MAC address), and the current time. Then, delete any other entries for that user.

    Then, when the user is working in the application and needs to make a transaction, query for the user's key entry in the DB. If it matches, allow the transaction. If not, they have more than one instance open and you can lock out the older instance of the application (or make it shut itself down).

    As long as you clear the user's key entries on startup, dropping network connections or abnormal shutdowns shouldn't matter.

  5. #5
    Join Date
    Sep 2000
    Location
    FL
    Posts
    1,452

    Re: Allowed No. of Sessions for User

    If you just want them to stop using more than one copy on the same computer, look at App.PrevInstance. If you are looking locking out users on multiple systems, then Something like WOF suggested would be good.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured