javascript - sessionStorage.clear() not working -
i'm using sessionstorage in project, 1 caveat: can't eliminate storage clear()
operator, documented.
i'm doing when logging out of administrative mode of site, involves clicking on log out item in list, this:
<li><a href="admin_logout.php">log out</a></li>
the admin_logout.php
file destroys session variables, etc., , redirects home page of site. previous form, works, is:
<?php session_start(); session_destroy(); @header('location:./'); exit; ?>
that works fine. can't seem integrate routine clearing sessionstorage. text of admin_logout.php
file, i've tried:
<?php session_start(); ?> <script> sessionstorage.clear(); </script> <?php session_destroy(); @header('location:./'); exit; ?>
...as as:
<?php session_start(); echo '<script>'; echo 'sessionstorage.clear();'; echo '</script>'; session_destroy(); @header('location:./'); exit; ?>
perhaps pointing root cause when i've placed:
?> <script> alert("hello"); </script> <?php
...within script, alert never executed, yet else is. how can invoke <script>
based sessionstorage.clear()
operation clear session storage items within routine listed above?
i think it's because you're redirecting on server-side , sessionstorage.clear()
happening on client side. believe you're redirecting before gets chance run.
Comments
Post a Comment