【发布时间】:2017-06-10 11:37:14
【问题描述】:
$_SESSION['profile_updated']="yes";
设置会话变量!
<div class="col-md-12">
<?php if(isset($_SESSION['profile_updated'])){ ?>
<div class="confirmationmsgssg">Profile Updated successfully.</div>
<?php unset($_SESSION['profile_updated']); } ?>
<h3>Your personal info</h3>
</div>
我正在尝试使用会话显示警报消息..
实际上这是一个增强项目,我无法更改整个代码,因为它存在于很多页面中
代码实际发生的事情首先是在视图页面中检查,例如$_SESSION['profile_updated'] 是否显示消息,它会在 3 秒后自动消失......当我刷新页面时,该消息不应该出现,因为我没有更新任何东西,我必须使用 unset..
如果我删除
unset($_SESSION['profile_updated']);,它工作正常 这个未设置。但是当我添加这个时,我不知道为什么它不起作用
我到处检查session_start(); 在我的第一行 php
可能是什么错误..?
我试过ob_start();没用..!
【问题讨论】:
-
<div class="col-md-12"> <?php if(!empty($_SESSION['profile_updated'])){ ?> <div class="confirmationmsgssg">Profile Updated successfully.</div> <?php $_SESSION['profile_updated'] = ''; } ?> <h3>Your personal info</h3> </div>
标签: php session variables unset