Determine how long user has been inactive

Is there an easy way to determine how long a user has been inactive on the page?
I thought sessions would do the trick but if I try to get lastActivity, it fails (Kirby 4).

The idea is to do some animation for the first time a user visits the page, like a welcoming animation. But I don’t want to bother each time he gets to the main page with the animation.

Any ideas, hints or thoughts?

You could set a cookie on the client side first time the user visits the page, if the cookie is still set, don’t trigger your animation.

Thank you. This would have been my second solution. Is this maybe something you can make available in the future, the value is here, it is just not acceptable.

What do you mean, what value is there?

Kirby doesn’t store anything about your visitors by design, so there are is no session cookie created unless a user logs in, see Kirby & Privacy | Kirby CMS.

And therefore, such a feature to track user data will never be implemented out of the box.

I See. I missunderstood. I saw the “lastActivity” in the session. I guess this is only for logged in users.

I solved it with the cookie. Thank you.