0

I want to set a SESSION value in php then remove it via JavaScipt like

  <?php 
     session_start()
     $_SESSION['newKey'] = "New Value";
  ?>

Then Remove it on javascript like

<script>
sessionStorage.clear() 
//or
sessionStorage.removeItem('newKey')

</script>
  • At first, you need to check how the session is set on the server directives. If the cookie is http-only, you can't do anything with JS. – Teemu Jun 08 '22 at 04:26
  • 4
    session in PHP (i.e. on the server) is not at all related to `sessionStorage` in the browser, and is not directly accessible in the browser either - in other words, what you want to do is not as simple as you want it to be – Bravo Jun 08 '22 at 04:29

0 Answers0