Php session expiration time issue

  ios, question

Usesession.gc_maxlifetimeIf set, the probability isgc_probability/gc_divisor;
I don’t understand why this regulation is necessary. This does not understand the principle

Discovery session monitors whether the user is active, and then automatically updates the last modification time of the session file.

Therefore, a function was written to read the last modification time of the session file, and then compared with the current time. If it is greater than the set expiration time, it is assumed to be 10 minutes. The information of the corresponding session is cleared. Is this ok?

Is there a better way?

Ps: I mean the expiration time when there is no activity.

Ps: My question does not consider setting an independent expiration time for the value of each session;