Sessions are stored server-side, so you cannot add values to them from JavaScript. All you get on the client side is the session cookie containing the id. One possibility is to send an AJAX request to a server-side script, which will set session variables. jQuery’s .post() method example:
Sessions are stored server-side, so you cannot add values to them from JavaScript. All you get on the client side is the session cookie containing the id. One possibility is to send an AJAX request to a server-side script, which will set session variables. jQuery’s
.post()
method example:Of course, you should be careful about exposing such scripts.
In JavaScript:
In the session_write.php file:
In HTML: