1

I'd like to create a history section so logged in users can see which pages they have visited.

Is there a way to post an entry without using a form? So the user does not have to click to say he has visited a page, instead as soon as they visit the page it is logged into a history section (the user and the page slug)

I've thought about doing it with javascript but it seems a little messy. Is there a native neat way to do this? Or a simple way to achieve it with a plugin?

Thanks in advance :)

1

If you're looking for an "audit trail" of pages a user has visited, then a plugin will be the way to go.

You'd want to track a user by something like their PHP session ID. And for every request grab that session ID and the URI and save that in a your plugin's dedicated audit table in the database (no need to use entries for this).

When the user goes to their history page, you'll query your audit table and grab any rows with a matching PHP session ID and display them however you want.

  • What's the advantage of using the PHP Session ID as opposed to their username? Will that remain constant for users across devices and logins? I'm not so interested in recording anonymous users. – j00lz Nov 15 '14 at 3:47
  • If you're requiring them to be logged in, then nothing... use the username. I was just assuming they wouldn't be logged in. – Brad Bell Nov 15 '14 at 3:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.