6 Replies Latest reply on Jun 9, 2010 11:23 AM by ninja

    Counting the number of times someone logs in...

    AAgraphics

      Title

      Counting the number of times someone logs in...

      Post

      FMP 10, hosted on a remote server, clients using FMP 10 on mac and PC and IWP

       

      All users have unique usernames and passwords.  How can I keep track of the number of times a username is used to log in to the database?  Also, is there a way I can keep track of how long the user is in the system?

       

      Finally, I think I would want this information to reset every week or month, any suggestions?  Thank you very much for your time!

        • 1. Re: Counting the number of times someone logs in...
          ninja

          Howdy,

           

          You can create a record in a "UsersLog" table and put in info by using your startup script including Get(AccountName) and Get(CurrentTimeStamp).

          You can create another record (or modify or add to the first one) in your exit script for exit time.

          You can then create reports or calculations from there.

           

          There are a number of ways to clear it out, including a record containing "Last cleanout date" and checking against this for elapsed time and re-clearing records again.

           

          If (Get(CurrentDate) > LastCleanoutDate + 30)

             GoToLayout [UserLog (UserLog) ]

             Show all records

             Delete All records

             SetField [ Admin::LastCleanoutDate ; Get(CurrentDate) ]

          EndIf

           

          or some such...

          • 2. Re: Counting the number of times someone logs in...
            AAgraphics

            I have a users table.  How do I build the login script to get account name and make a calculation in that record so I can place the time stamp and other information?  Sorry, little bit of a FMP novice.  Thanks!

            • 3. Re: Counting the number of times someone logs in...
              philmodjunk

              You can use file options to select scripts to run when the file is opened or closed.

               

              A script such as:

               

              Enter Find Mode []

              Set field [UserLog::AccountName ; Get ( AccountName ) ]

              Perform FInd[]

              Set Field [UserLog::LogCount ; UserLog::LogCount + 1 ]

              Set FIeld [UserLog::TimeIn ; Get ( CurrentTimeStamp ) ]

               

              etc.

               

              can capture log in data.

               

              and a similar script running at file close can log the timestamp when the user logged out.

              Keep in mind though that if a user's copy of filemaker crashes or they are disconnected from the network, the "close" script won't run and your UserLog will still show the user as being logged in when they aren't.

              • 4. Re: Counting the number of times someone logs in...
                ninja

                Assuming that your users table is ONLY used for user tracking:

                 

                Make five fields on your Users table: Account (text), Entry (timestamp) and Exit (timestamp) and RecordID (autoenter serial) and gID(global text).

                Make a layout based on this table called "Users" (you probably already have this)

                 

                In your startup script (File>File Options, When opening this file Perform Script....) have something like:

                 

                Freeze Window

                GoToLayout [ "Users" (Users) ]

                New Record/Request

                SetField [ gID ; Users::RecordID ]

                SetField [ Users::Account ; Get (AccountName) ]

                SetField [Users::Enter ; Get (CurrentTimeStamp) ]

                GoToLayout.........add the rest of your startup script here....if you don't have any more, choose the layout you want them to start on.

                ReFresh Window

                 

                In your Exit Script (File>File Options, When closing this file Perform Script....) have something like:

                 

                Freeze Window

                GoToLayout ["Users" (Users) ]

                Enter Find Mode

                SetField [RecordID ; Users::gID]

                Set ErrorCapture [on]

                Perform Find

                SetField [Users::Exit ; Get(CurrentTimeStamp) ]

                 

                Get to this point and we'll work on the clearing out part...

                Keep in mind how many log ons and log offs there will be.  How many records would this make in 30days?  enough for the find to slow your system down?  That could be a problem for you...  How many would you expect?  If there are a lot, we can approach this a slightly different way.

                • 5. Re: Counting the number of times someone logs in...
                  AAgraphics

                  Thank you so much!!!

                   

                  How would I write a calculation so I could say:

                   

                  "  'John Doe' logged in X times in the past seven days "

                  • 6. Re: Counting the number of times someone logs in...
                    ninja

                    Well, it depends.

                     

                    How would you like to define it?  Will it be for a manually selected user, all users, always seven days, do you need to store these results?

                     

                    I guess the question is: What type of reviewing would you do?

                    Then we'll build an interface to give you that.

                     

                    One way to review the usage would be a sub-summary report sorted by user.  Phil wrote a nice tutorial on subsummary reports that you can find here:

                    http://fm.lithium.com/t5/Using-FileMaker-Pro/Creating-Filemaker-Pro-summary-reports-Tutorial/m-p/46894/highlight/true#M36603

                     

                    Another way would be to have a layout where you typed in the start and end dates of interest and have the users listed with the number of logins each one had between those dates (filtered portal)

                     

                    If you are simply looking for abuse or neglect, you could define parameters that suggest these and calculate these.

                     

                    There are many options, which make sense in your situation?