PHP Script for last login time

I found it.

After a lot of research I found the way to hook into logout and get user data, and as i was looking for that i found the exact answer i was looking for.

function users_last_login() {
    $cur_login = current_time('mysql');
    $userinfo = wp_get_current_user();
    update_user_meta( $userinfo->ID, 'last_login', $cur_login );
}
add_action('clear_auth_cookie', 'users_last_login', 10);

Thanks for the help guys 🙂

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)