Cannot update prev_last_login, last_login and last_action for Users (Elgg 2.3.8)

I am trying to manually update the prev_last_login, last_login and last_action parameter for the users but It seem like my code is not working as the parameters are not getting updated.

Here is my code

$time = time();
$user = get_user($guid);
$user->prev_last_login = $user->last_login;
$user->last_login = $time;
$user->last_action = $time;
$user->save();

Can anyone tell me where am I making the mistake.