According to the PHP documentation on Sessions and security:
Executing the session_regenerate_id() function could result in Dos attack, in the same way as use_strict_mode=On. However, Dos is still better than an exposed account. Session ID must be renewed at least when the user authenticates. Renewing the session ID reduces the risk of stealing session ID, so it should be run periodically. The developer should not depend on the expiration of the session ID. Attackers can access the victim’s session ID periodically to prevent it from expiring. Developers must implement their own expiration means for older sessions.
See what the text says: for once, it doesn’t mean you can’t do every page.
You should analyze the situation you are using and the time your sections stay open.
For example: in a system I maintain, where sections remain for a long time, I call the method session_regenerate_id()
every time a PHP script is called.
In other situations, you can set use in authentication.
the purpose is to prevent session theft
– Otavio Fagundes
I find a kind of silly way to avoid session theft. To "steal" the session, first you need to traffic without HTTPS, and someone is monitoring. If you keep changing the ID, the user himself may have problems with several open tabs etc - I find it more interesting to do a separate control. But any more serious application will use HTTPS, and it makes no sense to generate new ID that way. I find it more interesting if you use this to renew session, for example, to avoid timeout because of the cookie. If the person has the technology to steal the old ID, he sees the new passing the same way.
– Bacco