php - Identify if user has watched a video


I am developing an application that requires a user to view a set of videos.

How can I identify if the user has watched a particular video(complete and incomplete)?




You could embed the video on a page on your website, so you can register it that way.

You could also put a URL at the end of the video that they must follow to register they've seen the video.

I hope that the answer is "you can't" if you're talking about having watched it directly from YouTube.




You can use php's session variables, and put each video on a different webpage. Then when one video ends it redirects to another webpage and adds a value to that session. Before each page is loaded the session checks to see if the user should be on that webpage like so:

if($_SESSION['videos']=="whatever value"){ //check to see if the session equals what value it should
$_SESSION['videos'] = 'whatever value2'; //update the value for next webpage
else { //if session variable doesn't equal what it should, redirect to homepage

and to figure out when the video ends, just set a timer to the exact length of the video. I think you can figure that out for yourself.




Ah youtube videos. I made a YouTube Client that could do exactly what your referring to. It was a Client side URL sniffer that checked various urls for the presence of a youtube video ID. It could detect when a video was watched embedded in a site and many other places where the video could be watched.

Unfortunately, Firefox has changed their JS Engine to disallow URL sniffers, so finding if youtube videos have been watched via javascript is now out of the question. Your last option might be to authenticate the user under their youtube account and check the History. Good Luck!

People are also looking for solutions to the problem: Facebook: Post on Page as Page issue (access token / php)


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.