Is it recommended to assign a new session to a user on every login or revisit to a website in PHP?

It is not recommended to assign a new session to a user on every login or revisit to a website in PHP as it can lead to unnecessary session creation and potential performance issues. Instead, it is best practice to assign a session only once during the initial login and then maintain the same session throughout the user's visit to the website.

session_start();

if (!isset($_SESSION['user_id'])) {
    // Perform login authentication and set session variables
    $_SESSION['user_id'] = $user_id;
    $_SESSION['username'] = $username;
    // Other session variables can be set as needed
}