local STORAGE_LAST_LOGIN_TIME = 99992

function onLogin(player)
    player:setStorageValue(STORAGE_LAST_LOGIN_TIME, os.time())
    return true
end

function onLogout(player)
    local loginTime = player:getStorageValue(STORAGE_LAST_LOGIN_TIME)
    if loginTime > 0 then
        local sessionSeconds = os.time() - loginTime
        local total = player:getStorageValue(99993) -- STORAGE_ONLINE_SECONDS
        if total < 0 then total = 0 end
        player:setStorageValue(99993, total + sessionSeconds)
    end
    return true
end