Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>My solution to the problem is the following. You can find the function <code>http_digest_parse</code> , <code>$realm</code> and <code>$users</code> in the second example of this page: <a href="http://php.net/manual/en/features.http-auth.php" rel="nofollow noreferrer">http://php.net/manual/en/features.http-auth.php</a>. </p> <pre><code>session_start(); function LogOut() { session_destroy(); session_unset($_SESSION['session_id']); session_unset($_SESSION['logged']); header("Location: /", TRUE, 301); } function Login(){ global $realm; if (empty($_SESSION['session_id'])) { session_regenerate_id(); $_SESSION['session_id'] = session_id(); } if (!IsAuthenticated()) { header('HTTP/1.1 401 Unauthorized'); header('WWW-Authenticate: Digest realm="'.$realm. '",qop="auth",nonce="'.$_SESSION['session_id'].'",opaque="'.md5($realm).'"'); $_SESSION['logged'] = False; die('Access denied.'); } $_SESSION['logged'] = True; } function IsAuthenticated(){ global $realm; global $users; if (empty($_SERVER['PHP_AUTH_DIGEST'])) return False; // check PHP_AUTH_DIGEST if (!($data = http_digest_parse($_SERVER['PHP_AUTH_DIGEST'])) || !isset($users[$data['username']])) return False;// invalid username $A1 = md5($data['username'] . ':' . $realm . ':' . $users[$data['username']]); $A2 = md5($_SERVER['REQUEST_METHOD'].':'.$data['uri']); // Give session id instead of data['nonce'] $valid_response = md5($A1.':'.$_SESSION['session_id'].':'.$data['nc'].':'.$data['cnonce'].':'.$data['qop'].':'.$A2); if ($data['response'] != $valid_response) return False; return True; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload