Solution 1 :

If I understand it right, you want to read some value stored in session (in php stored in $_SESSION) as a client from javascript.

First: session is server-side thing, clients don’t know that they are in session.

But there is a way, how to send value.
This is what came to my mind:

<h2 id="titlesystem"></h2>
<p id="bodysystem"></p>
<input type="hidden" value=<?php echo $_SESSION["value"]?> id="mySessionValue">
<script>
    var sessionValue = document.getElementById("mySessionValue").value;
    if (sessionValue == 1)
    {
        document.getElementById("titlesystem").innerHTML = "Your System";
        document.getElementById("bodysystem").innerHTML = "Amazing!"
    }
</script>

Problem :

I want the script to read the global element, detect if its value equals 1 and if so, display a load of text but for some reason it doesn’t seem to work.

var z = sessionStorage["system"]
if (z == 1) {
  document.getElementById("titlesystem").innerHTML = "Your System";
  document.getElementById("bodysystem").innerHTML = "Amazing!
}
<h2 id="titlesystem"></h2>
<p id="bodysystem"></p>

Comments

Comment posted by KIKO Software

There’s no PHP in your code, why did you use that tag?

Comment posted by mplungjan

You do not need the wrapping

Comment posted by mplungjan

Do you mean

Comment posted by M. Eriksson

innerHTML = "Amazing!

Comment posted by M. Eriksson

You should also include what debugging you’ve done. Do you have any errors in the console? Have you checked that

Comment posted by window.sessionStorage

JS has

By