Debugging a PHP program, is there any add-on/plug-in for browser which I can view sessions variables (those PHP $_SESSION["foobar"] )?
Best if I can change the value in the variables.
There is no way to manipulate the values stored in sessions from the client side. That's one of the main reasons you'd use a session over a cookie - YOU control the data. With cookies, the user can manipulate the data.
# View sessionStorage keys and valuesClick the Application tab to open the Application panel. Expand the Session Storage menu. Click a domain to view its key-value pairs. Click a row of the table to view the value in the viewer below the table.
Session variables on the client are read-only. They cannot be modified. In order to change the value of a session variable, an Ajax Callback is required. Similarly, if a session variable changes on the server, it will not be updated on the client until an Ajax Callback is made from the client.
That's one of the main reasons you'd use a session over a cookie - YOU control the data. With cookies, the user can manipulate the data.
The only way to access/manipulate session data from the client side would be with an Ajax call or other JavaScript mechanism to call another php script, which would be doing the retrieval/manipulation of the session data via the session_
functions.
$_SESSION
is a server-side array of variables. If we could read or change the values, there are many things that we could do to hack or cause other bad things to happen.
However, using phpinfo();
we can view session variables - but we cannot change the value.
Even better, we can debug all session variables with
print_r($_SESSION); //if you echo "<pre>" before, and a closing "</pre>" after, it prints very cleanly.
some other useful commands:
session_start(); // start session -- returns Session ID session_destroy(); // unset all session variable
Session is an array so if you set $_SESSION['key']='value';
it is same like $array['key']=value;
- only, what is special about $_SESSION - is that it persists until the window is closed, or session_destroy()
is called.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With