使用受密码保护的页面调用iframe - 我可以隐藏我的凭据吗?

时间:2013-09-02 15:11:49

标签: html authentication iframe password-encryption

我只是想知道我是否可以在iframe上隐藏我的信用,因为我在iframe中调用服务器端密码保护页

<iframe src="http://username:password@domain.com/index.php">
   <p>Your browser does not support iframes.</p>
</iframe>

由于

1 个答案:

答案 0 :(得分:0)

你可以做的是创建2个编程,第二个将显示iframe。

  1. 创建会话
  2. 显示iframe(如果用户和密码正确)
  3. 调用iframedisp.php的iframegoto.php,后者又显示iframe。

    <强> iframegoto.php

    <?php
    session_start();
    $_SESSION['userName'] = 'userName';
    $_SESSION['passwprd'] = 'passwprd';
    header('Location: http://YourURL/iframedisplay.php');
    ?>
    

    <强> iframedisplay.php

    <?php
    session_start();
    if (isset($_SESSION['userName']) and 
    $_SESSION['passwprd']=="passwprd" and $_SESSION['userName']=="userName")
    {
    echo "Welcome : ".$_SESSION['userName'];
    echo "<iframe width='100%' height='100%' frameborder='0' src='http://whatever.com'></iframe>"; 
    }
    else echo "You are not Authorised";
    ?>
    
相关问题