You can’t assign javascript variable value to php variable, but you can assign php variable value to javascript variable. You will have to pass it through the url or pass it using ajax to some file and assign the javascript value to php session in that file.
Also i see that variable data1 is a ajax success response, which means it is already in the php file session.php, so why don’t you just assign that response in session in session.php file??
will execute when the page is first drawn, and not when the Ajax call returns. PHP is only processed on the server, not on the client side. By the time your Ajax call runs and returns, the PHP processing has already finished.
That seems to be the way, set it in the php file that you call via Ajax.
If you’ve used PHP in your main page to recover the value of the session variable, it won’t automatically change, for the same reason - the main PHP is only processed when the page is first drawn.