记录在Cookie,就免除了每次输入密码了

解决方案 »

  1.   

    去搜索一个cookie验证登录程序
      

  2.   

    这是一个需要basic Authentication,即HTTP 验证的页面,一般可以这样来写:
    <?php
    $username = $_SERVER['PHP_AUTH_USER'];
    $password = $_SERVER['PHP_AUTH_PW'];$u = "username";
    $p = "password";
    //  HTTP Basic authorization.
    if (!isset($username) || !isset($password) 
        || $username != $u 
        || $password != $p) {
        header('WWW-Authenticate: Basic realm="My Realm"');
        header('HTTP/1.0 401 Unauthorized');
        echo '帐号/密码错误!';
        exit;

    ?>
      

  3.   

    加入用户名为username,密码为password,则需要请求的时候发送一个请求头,Authorization: Basic xxxxxxxxxxxxxxxxxxxxxxxxxxxx ,其中xxxxxxxxxxxxxxxxxxxxxxxxxxxx代表base64_encode("$username:$password") 。
    在php中用curl访问该页面时,只要设置一下curl的CURLOPT_USERPWD就可以了,即curl_setopt($ch, CURLOPT_USERPWD, "$username:$password")
      

  4.   

    http://www.zend.com/forums/index.php?t=msg&goto=3722&S=cdb2a702c53478d2ccebe24b65e1cbe5#msg_num_1