Is using JavaScript a viable alternative to storing user data for returning to the last visited page, especially in terms of server performance?

When storing user data for returning to the last visited page, using JavaScript can be a viable alternative to reduce the server load and improve performance. By storing the data in the user's browser using JavaScript, the server does not need to handle and process the data, resulting in faster response times and reduced server load.

// PHP code snippet to set a cookie with the last visited page URL
$lastVisitedPage = $_SERVER['REQUEST_URI'];
setcookie('last_visited_page', $lastVisitedPage, time() + 3600, '/');