简体   繁体   中英

PHP - How to create a pop up alert box before an unset session

I want to let an alert box pop up after a user's session expire. My problem is I can't the alert box isn't displaying.

The alert box isn't working if I put the unset session but it'll work if there is no unset session. I know using alert('') isn't ideal so I'm wondering if there's a simple way to create such pop up.

My code is something simple like this

echo "
<script>
alert('Your Session has expired for inactivity. Please log in again');
</script>";
unset($_SESSION['admin_log']);
unset($_SESSION['admin_time_log']);
?>
<script>
alert('Your Session has expired for inactivity. Please log in again');
</script>
<?php
unset($_SESSION['admin_log']);
unset($_SESSION['admin_time_log']);
?>

Try this way. This work. It is working in my case.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM