As far I’ve researched there are two ways in my mind to achieve this and they are-
- Database: Save the value of the current page ID in the database for the user and continuously update it. That way you can get the last visited page by a user. You can store multiple page visit stat as serialized data in database. Though it is kinda performance reducer but it’s effective. And it saves the data which you can use later for any kinda query.
- Session: You can also use
session
to store the previous page ID and this way you can get the last visited page. Atsession
destruction you can get the data bysession_set_save_handler
Hope those above ways are gonna help you.