Search code examples
javascriptphpsession-storage

Using PHP - is it possible to set SessionStorage in the browser?


Im pulling in a $_SESSION variable coming from my database, either: $_SESSION['lvl'].

After the level is fetched, I'd like to store that variable in the browser's session as key value pairs using the sessionStorage API; is this possible?

I do not see any docs or info as it looks like this is only possible using JavaScript.

I'd like to set it within my PHP service.

Any advice is appreciated.


Solution

  • Well, you need to produce Javascript code that will do it on the client, and it's gonna be a pain to get the value on the server side.