[英]having trouble destroying a session variable
I want to unset a session variable when a popup is closed using jQuery. 我想在使用jQuery关闭弹出窗口时取消设置会话变量。 The jQuery code is as follows:
jQuery代码如下:
$("#close").click(function (){
$("#popup_container2").css("display", "none");
if($("#popup_container2").css("display")=="none")
{
var s=1;
$.post("check_data.php", "s=" + s, function(respose){
location.reload();
});
}
});
This popup block will be opened when the page loads only if $_SESSION['question_temp_id']
is set. 仅当设置了
$_SESSION['question_temp_id']
时,才会在页面加载时打开此弹出框。 Else it won't. 否则不会。 For this, I have added this code in the body tag.
为此,我已在body标签中添加了此代码。
if(isset($_SESSION['question_temp_id'])) {
echo 'onLoad="div_show();"';
}
On the check data page, the php code is as follows. 在检查数据页面上,php代码如下。
if(isset($_POST['s']) && $_POST['s']==1) {
unset($_SESSION['question_temp_id']);
}
The problem is that popup still opens even though I have unset that session variable. 问题是即使我未设置该会话变量,弹出窗口仍会打开。 I can't figure out the problem here.
我在这里找不到问题。 Please suggest.
请提出建议。
Thanks in advance. 提前致谢。
if(isset($_POST['s']) && $_POST['s']==1) { unset($_SESSION['question_temp_id']); }
question_temp_id
instead of set/unset. question_temp_id
实际值而不是设置/取消设置。 You may use Y/N value. Actually, the problem was that I hadn't used session_start
in the start. 实际上,问题是我一开始没有使用
session_start
。 Since there was a lot of code, so it was difficult to find the problem. 由于有很多代码,因此很难发现问题。 However, later I found it out and corrected it and now, code works fine.
但是,后来我发现并纠正了它,现在,代码可以正常工作了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.