I'm running FreeRADIUS in conjunction with PostgreSQL 9.1. Snippet from radiusd.conf:

modules {

...
        $INCLUDE sql/postgresql/counter.conf
...

}

in my sql/postgresql/counter.conf, I have the following:

sqlcounter dailycounter {
        counter-name = Daily-Session-Time
        check-name = Max-Daily-Session
        reply-name = Session-Timeout
        sqlmod-inst = sql
        key = User-Name
        reset = hourly

        query = "SELECT SUM(AcctSessionTime - GREATER((%b - AcctStartTime::ABSTIME::INT4), 0)) FROM radacct WHERE UserName='%{%k}' AND AcctStartTime::ABSTIME::INT4 + AcctSessionTime > '%b'"
}

Attention!!! The "dailycounter" has an hourly reset.

in the sites-available/default, under authorize section:

authorize {

...
dailycounter
...
}

Now in my database. I have in "radcheck" table two rows: 

   id  |     username      |     attribute            | op |   value    
  -----+------------------------+----------------------------+----+------------
 167 | test1                 | Password              | := | test1
 168 | test1                 | Max-Daily-Session | := | 60

The problem is that every time when I authenticate for the first time per hour (because the sqlcounter is resetted hourly), with username test1, I can access the services given by freeradius an unlimited time. The sqlcounter is ebanled only if after I log in first time, log out and log in again. If I exceed the time specified in the radcheck table in the first log in, at the second login (in the same hour), I cannot login again due to the sqlcounter that says that the time is up.

Question: can anyone help me how to put the right settings in database or FR' files so that the sqlcounter module will work from the first login?