I know you said you were not a C programmer, but the easiest way I've found to minutely track logins is still to read the wtmpx entries directly with the getutxent C library call. That said, I believe you may be attacking the problem from the wrong angle.
Take a step back and look at the...