I have a site that logs a user in and does a db lookup to see if the user has acknowledged that they have read a file. If they have not they are sent to a page with links to the files which need to be read. Once they read the file and click the acknowledge link the php script adds this file name along with user name to a table named read. What I want to do is stop the user from navigating away from this page if they have not acknowledged that they read the files. How would I use the javascript onunload function and do an ajax request to check if they have read the files that need to be read. I am new to ajax so any help would be appreciated.
Share
Best way to handle this is PHP, not JS. Too easy to get around it if you depend on JS:
1) when loading the user data into the session, check if they acknowledged it or not.
2) add a condition to fire on every page load (same place in the code where you check if they are logged in) in php that will redirect them to that page unless they have acknowledged it.