title: Prevent HTML5 video from being downloaded with PHP
body: <p>This code prevent HTML5 video from being downloaded and only display video.</p>
  
  <p>It works great in Firefox browser but it does not work in Chrome and Safari browsers! Does anyone knows the problem?</p>
  
  <pre><code>&lt;?php
  ini_set('session.use_cookies',1);
  session_start();
  
  $mp4 = uniqid(); 
  $_SESSION[$mp4]='a.mp4';
  echo '&lt;video autoplay="autoplay"&gt;'
      .'&lt;source src="video.php?video='.$mp4.' type="video/mp4"&gt;'
      .'&lt;/video&gt;';
  ?&gt;
  </code></pre>
  
  <p>video.php</p>
  
  <pre><code>&lt;?php
  ini_set('session.use_cookies',1);
  session_start();
  $file='myhiddenvideos/'.$_SESSION[$_GET['video']];
  $_SESSION=array();
  $params = session_get_cookie_params();
  setcookie(session_name(),'', time()-42000,$params["path"],$params["domain"], $params["secure"], $params["httponly"]);
  if(!file_exists($file) or $file==='' or !is_readable($file)){
    header('HTTP/1.1 404 File not found',true);
    exit;
    }
  readfile($file);
  exit;
  ?&gt;
  </code></pre>