doujiang1939 2013-02-04 08:12
浏览 122
已采纳

无法设置http_referer

How can I set my http_referer location in my logout.php page after signin(using signin.php) which checks & successfully login redirects to joomla.php where i gave logout link(using a href) now i want to click on logout & go to `signin. php & i got http_referer is joomla.php so hw can i set logout.php

  1. Code: Signin.php

    $referer = $_SERVER['HTTP_REFERER'];
    echo $referer;
    if ($referer == 'http://localhost/MinProject/reg.php')
    {
        echo "Registration SuccessFully";
    }
    
    else if($referer=='http://localhost/MinProject/changepassword.php')
    {
        echo"Change Password SuccessFully";
    }
    
  2. joomla.php

    <html>
        <body>
            <table width="100%">
                <tr>
                    <td width="20%" height="32" align="right" class="unm">
                        <?php
                        session_start();
                        if(isset($_SESSION['username']))
                        {
                            $name =$_SESSION['username'];
                            echo "Welcome ".$name;
                         }
                        ?>
                    </td>
                    <td width="64%" height="32" align="right">
                        <a href="changepassword.php">ChangePassword</a>
                    </td>
                    <td width="10%" align="right">
                        <a href="logout.php">logout</style></a>
                    </td>
                    <td width="11%"></td>
                    <td width="5%"></td>
                    <td width="5%"></td>
                    <td width="5%"></td>
                </tr>
            </table> 
        </body>
    </html>
    
  3. logout.php

    session_start();
    unset($_SESSION['username']);
    session_destroy();
    response.setHeader("Location: http://localhost/MinProject/logout.php");
    header("Location: Signin.php");
    exit();
    
  • 写回答

1条回答 默认 最新

  • doubei5114 2013-02-04 08:54
    关注

    HTTP_REFERER can be spoofed so you should not use that.

    Looking at your code i think you are trying to achieve.

    $Message  = $_SESSION['MESSAGE'];//set the message Registration SuccessFully if registration else set it as Change Password SuccessFully or accordingly
    if (isset($Message) and userhasidentity)
    {
        echo $Message;
    }else
    {
       header('location:logout.php');
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥30 BC260Y用MQTT向阿里云发布主题消息一直错误
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退