如果会话已经限制,我想在php中进行确认弹出(是/否按钮)。如果用户在弹出窗口中单击是按钮,则保留在网站或刷新会话中,如果单击否,则会话终止。我怎么能这样做?..下面是我的PHP代码:
if (isset($_SESSION['LAST_ACTIVITY1']) && (time() - $_SESSION['LAST_ACTIVITY1'] > 7200)) {
if (isset($_SESSION['member_id'])) {
***<script>comfirmation popup code in here</script>***
session_unset(); // unset $_SESSION variable for the run-time
session_destroy(); // destroy session data in storage
header('Location: '.AT_BASE_HREF.'login.php?loginexpired=true');
exit;
}
//echo "awa";
} else {
//echo "aba" . $_SESSION['LAST_ACTIVITY1'];
}
我的问题我不能把javascript代码放在php里面。如何将jquery的javascript放入php?
这是我想要的代码:
<script type='text/javascript'>
var answer = confirm ("Are you having fun?")
if (answer)
alert ("Woo Hoo! So am I.")
else
alert ("Darn. Well, keep trying then.")
session_unset(); // unset $_SESSION variable for the run-time
session_destroy(); // destroy session data in storage
//header('Location: '.AT_BASE_HREF.'login.php?loginexpired=true');
window.location.href="<?php AT_BASE_HREF.'login.php?loginexpired=true'; ?>";
// -->
</script>
答案 0 :(得分:0)
尝试以下代码
if (isset($_SESSION['member_id'])) {
?>
<script type='text/javascript'>
alert('test');
</script>
<?php
session_unset(); // unset $_SESSION variable for the run-time
session_destroy(); // destroy session data in storage
?>
<script type='text/javascript'>
location.href="<?php echo AT_BASE_HREF.'login.php?loginexpired=true'?>";
</script>
<?php
}
一定是工作。首先检查警报框。