donglu9898 2015-03-27 01:26
浏览 39
已采纳

PHP会话未被传递

I am working on authentication for my schools username and password. The school has its own backend script to use for form POST. It allows some hidden inputs with specific names for customization, for example, page redirecting on success. However, I can't have any session_start() or any of my php code on that page because after the login.php, the login page gets redirected to the schools page and then gets redirected back to my index.php. The post value gets passed through to the index.php but on page refresh, it goes back to the login page because the session is not saved with the post value.

Any help on this will very helpful.

Index.php

<?php
session_start();
$_SESSION['username'] = $_POST['sid'];
if(!isset($_SESSION['username'])){
header("Location: login.php");
} else {
?>
// HTML here
<?php
}
?>

Login.php

<form action="authenticator.pl" name="form1" method="POST">
    // Using hidden inputs I specify which page to redirect to... These are specific hidden inputs that are accepted.
</form>
  • 写回答

2条回答 默认 最新

  • dongpa5207 2015-03-27 01:34
    关注

    If you're not sending post data to the index.php page the following line will clear the username session value.

    $_SESSION['username'] = $_POST['sid'];
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler