If you ask about whether or not it's possible to detect on the server-side if Javascript is enabled, then the answer is: technically no.
As the server process is not within the browser process, there is not way for the server to inspect if a feature or setting in the browser is enabled / exists.
You can however try to mimic that. E.g. scripts are not going to be loaded from the server-side if javascript is disabled (normally). Also you can insert javascript that will do specifically crafted requests to your server so that you know something is disabled.
<noscript><img src="http://example.com/session-trigger-js-disabled.php?.gif" width="0" height="0"></noscript>
<script src="http://example.com/session-trigger-js-enabled.php?.js"></script>
Note: $_SESSION
in PHP can be blocking. The <script src="url">
tag is also blocking, so take care that you're not creating "deadlocks" that will decrease the user-experience with your website.
A more lightweight approach might be to set a cookie and change it if javascript is enabled. Cookies can be read out by PHP, their nature is not blocking and you don't need to waste session for that.