Last 5 Visted Pages

Hi

I want to capture the last 5 visited pages for a given logged-in user into the database.

What would be the most efficient(minimal coding) way to capture that ?

Will I have to put the tracking code in every view page ?

or is there a better way ?

thanks for your reply

would track $_SERVER["REQUEST_URI"]; at bottom of /protected/views/layout/main.php work? rather than every view