douyin4875 2017-11-15 14:45
浏览 55
已采纳

是否可以在索引上使用相同的会话变量,而在没有cookie的情况下使用underpage?

I try to use the same session variable I created in localhost/project/underpages/page.php in localhost/project/index.php.

But if I check with var_dump it says null so there must be something wrong.

page.php

<?php
    session_start();
    $_SESSION['loggedin'] = true;
    header("Location: ../index.php?logged-in");
?>

index.php

  <?php
        session_start();
        var_dump $_SESSION['loggedin'];
    ?>

I thougt now must be written true and not null.

Can someone help me? Thank you

  • 写回答

1条回答 默认 最新

  • donkey199024 2017-11-15 14:56
    关注

    I just try your code and it works fine... When you go on localhost/project/underpages/page.php It redirect you to localhost/project/index.php?logged-in and then I got this statement path/index.php:3:boolean true

    I just notice that u use var_dump $_SESSION['loggedin']; without "()", so you need to use var_dump($_SESSION['loggedin']);, I hope that this will resolve your problem

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 基于单片机数字电压表电路组成及框图
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 unity第一人称射击小游戏,有demo,在原脚本的基础上进行修改以达到要求
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line