How can I check if a database value has changed since the last login or page reload in PHP?

To check if a database value has changed since the last login or page reload in PHP, you can store a timestamp of the last login or page reload in a session variable. Then, compare this timestamp with the timestamp of the last update to the database value. If the database value has been updated after the last login or page reload, you can take appropriate action.

// Store timestamp of last login or page reload in session
session_start();
if (!isset($_SESSION['last_login'])) {
    $_SESSION['last_login'] = time();
}

// Get timestamp of last update to database value
// Assuming $lastUpdate is the timestamp of the last update to the database value
// Replace this with your actual database query to get the timestamp

// Compare timestamps
if ($lastUpdate > $_SESSION['last_login']) {
    // Database value has changed since last login or page reload
    // Take appropriate action here
}