PHP: HTTP Basic - Log off

前端 未结 3 923
一生所求
一生所求 2021-01-06 04:25

I would to set it up where if someone sends in a request \"logout\" it will automatically take them to a page saying \"successful log out\". If the customer tries to press t

3条回答
  •  星月不相逢
    2021-01-06 04:52

    You can use the meta tag http-equiv="refresh" with a very short response time (e.g. content="1"). This refresh will clear any $_POST.

    if ( !isset($_SERVER['PHP_AUTH_USER']) || $_SERVER['PHP_AUTH_USER']!='myusername' || $_SERVER['PHP_AUTH_PW']!='mypassword' || isset($_POST['logout']) ) {
        header('WWW-Authenticate: Basic realm="My protected area"');
        header('HTTP/1.0 401 Unauthorized');
        echo '401 Unauthorized

    401 Unauthorized

    You are not allowed to see this page. Reload the page to try again.

    '; exit(); }

提交回复
热议问题