diff options
Diffstat (limited to 'captain/db.f90')
-rw-r--r-- | captain/db.f90 | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/captain/db.f90 b/captain/db.f90 index 29c5810..97c397a 100644 --- a/captain/db.f90 +++ b/captain/db.f90 @@ -1654,6 +1654,7 @@ contains end subroutine update_session_db function session_expired_db(session) + use logging implicit none character(len=*), intent(in)::session @@ -1663,12 +1664,16 @@ contains session_expired_db = .true. - if(stmt%prepare(db, "SELECT COUNT(*) FROM sessions WHERE accessed < datetime('now', '-30 minutes') AND session=?") & + ! Statement should return the count of sessions that _has not_ expired! + if(stmt%prepare(db, "SELECT COUNT(*) FROM sessions WHERE accessed > datetime('now', '-30 minutes') AND session=?") & == SQLITE_OK) & then + if(stmt%bind_text(1, session) == SQLITE_OK) then if(stmt%step() == SQLITE_ROW) then + + ! If expired, the value would be 0... session_expired_db = .not. (stmt%column_int(0) > 0) end if @@ -1683,4 +1688,16 @@ contains end function session_expired_db + function is_valid_session_db(session) + implicit none + + character(len=*), intent(in)::session + logical::is_valid_session_db + + ! The call below will say a non-existent session is "expired," so whatever... + is_valid_session_db = (.not. session_expired_db(session)) + + end function is_valid_session_db + + end module captain_db |