dongmi4809 2017-05-10 10:48
浏览 63
已采纳

登录PHP后出现注销按钮

Problem: I want "logout" make instant appear if I'm logged. Now it only appears when I do Refresh (F5). Is there any way to make it instant appear after login?

<?php if ($gebruiker->checkLogout()) { ?>
  <li><a href="logout.php">Loguit</a></li>
<?php } ?>

function checkLogout()

function checkLogout(){
       if (isset($_SESSION['login'])) {
         return true;
       }else {
         return false;
       }
     }
  • 写回答

2条回答 默认 最新

  • douweidao3882 2017-05-10 10:55
    关注

    Make your code structure like:

    ---------------
    Logic for login
    ---------------
    
    ------------
    Menu Section
    ------------
    

    With this structure, when user login is successful the SESSION are set at the top, so that you can check them in menu section and on that behalf you can show the logout button. In the current scenario the logic section is placed after menu section that's why you have to make another request to check it.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序
  • ¥15 多址通信方式的抗噪声性能和系统容量对比
  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录