0

I cannot access the javascript session using php session

sessionStorage.setItem("ABCpercent", 100);

php

$ABCPercent = $_SESSION["ABCpercent"];

unable to retrieve

  • Are you trying to set the local session storage in the client and access if from a php backend? – Andrew May 11 '21 at 04:16
  • yes, I just want to use session storage for a while since Im redirecting to another page and get the value to save it on database by retrieving it using php – Rowell Esguerra May 11 '21 at 04:19
  • 1
    `sessionStorage` in JavaScript saves/retrieves data on the "browser" -client side-, `$_SESSION` in PHP saves/retrieves data on the "server" -server side-, if you need to pass data between the browser and the server you have to send the data in a **http request**. – Accountant م May 11 '21 at 04:20
  • thanks, looking foward on it, Im still learning things for now, just a newbie hehe – Rowell Esguerra May 11 '21 at 04:24
  • 1
    `1`JS code with sessionStorage -> `2` use Ajax to send data to php file -> `3`using $_POST or $GET you can access sessionStorage value in php – Niklesh Raut May 11 '21 at 04:26
  • 1
    Recommended reading: [the difference between client and server side](https://stackoverflow.com/questions/13840429/what-is-the-difference-between-client-side-and-server-side-programming). This will help you understand the workflow between server and client. – El_Vanja May 11 '21 at 08:50

0 Answers0