How can you ensure that a new session ID is generated every time a user visits a page or reloads it in PHP?

To ensure that a new session ID is generated every time a user visits a page or reloads it in PHP, you can regenerate the session ID using the session_regenerate_id() function. This function will create a new session ID and keep the current session data. By regenerating the session ID on each page load, you can enhance the security of your application by preventing session fixation attacks.

<?php
session_start();

// Regenerate session ID
session_regenerate_id();

// Your code here
?>