【问题标题】:Warning: session_start(): Cannot start session when headers already sent [duplicate]警告:session_start():当标头已经发送时无法启动会话[重复]
【发布时间】:2019-09-25 17:49:34
【问题描述】:

我在第 58 行有错误 if(isset($_SESSION['username'])){ ,当我在 xampp localhost 上尝试它的工作并且没有错误但是当我托管到 000webhosting 时,它有很多错误

警告:session_start():当标头已在第 58 行的 /storage/ssd4/858/9397858/public_html/atasan.php 中发送时,无法启动会话 enter image description here

文件php在这里:

在这里删除了充满废话的链接。

链接托管: https://ayojalankuy.000webhostapp.com/

    <?php session_start();

if(isset($_SESSION['username'])){
?>
            <span class="element-divider place-right"></span>
            <div class="element place-right">                   
                <a class="dropdown-toggle icon-cog" href="#"></a>
                <ul class="dropdown-menu" data-role="dropdown">
                    <li><a href="profil.php">Profil</a></li>
                    <li><a href="booking.php">Booking</a></li>
                    <li><a href="bookingList.php">Cek Booking</a></li>
                    <li class="divider"></li>
                    <li><a href="logout.php">Keluar</a></li>
                </ul>
            </div>
            <a href="profil.php" class="element place-right">Selamat datang, <?php echo "$_SESSION[username]"; ?></a>

【问题讨论】:

  • 如果您想分享一些代码,请在此处进行,而不是在一些有 100 个弹出窗口和阻止您离开网站的内容的网站上。

标签: php mysql hosting web-hosting


【解决方案1】:

尝试将 session_start() 放在任何其他代码之前的顶部

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-06-24
    • 1970-01-01
    • 2017-08-29
    • 1970-01-01
    • 2018-01-29
    • 1970-01-01
    • 2013-09-11
    • 2020-07-02
    相关资源
    最近更新 更多