I want to insert javascript value into the php session variable but inside the javascript function.
Here is what I have tried and it is not working:
Javascript does not have access to PHP-variables. The client (web browser/javascript) only has access to the Cookie or Cookieless ID (Querystring) associated with the session.
Sessions are used this way for the purpose of not letting the client modify settings associated with the session without going through the server. The less "secure" way is to use cookies for all settings. Something like language-setting might be a good idea to store in a cookie rather than the session.
In order to solve this, you could make a page which takes a session property name (like your "SESS_LANGUAGE") and a value which puts it in the session using php. I strongly advise against this because any user could then set any session variable.
The best way I can imagine is that you send an AJAX-call to a page saying that you want to change the language.
The called URL would be something like this: changelanguage.php?lang=en_US
And the php-code for changelaguange.php: $_SESSION['SESS_LANGUAGE'] = $_GET['lang'];