javascript - best way to save sessionStorage before a header -
i want save sessionstorage item if rowcount happens 0, know shouldn't echoing before header, hence, please let me know best way set sessionstorage before headering on conditions. js , php, dont want use jquery. in advance !
<?php $admin_table = "admin_table"; $show_all_admins = "select * $admin_table"; $show_all_admins_query = mysqli_query($conn, $show_all_admins); $rowcount = mysqli_num_rows($show_all_admins_query); if($rowcount == 0 ){ mysqli_close($conn); echo'<script>sessionstorage.setitem("admin_sessn", "admins");</script>'; header('location: http://localhost/littlesidegym.php'); exit(); } ?>
one option handle redirect in javascript instead of php
<script> sessionstorage.setitem("admin_sessn", "admins"); window.location = 'http://localhost/littlesidegym.php'; </script>
Comments
Post a Comment