Check Whether Javascript is Enabled on Browser Using php |

Congrats, You are Subscribed to Receive Updates.

Check Whether Javascript is Enabled on Browser Using php

You can check js enable using php also.  From my previous article shows to check it using HTML5. Here I am giving you two ways to check it using php.  Php is server side scno-jsript, eventhough we can identify the client browser capability and work based on it.  First option is very simple code to perform it.

<script type="text/javascript">
  document.cookie = 'kvhasJS=true';
 // Kvcodes, js testing 

if (isset($_COOKIE['kvhasJS'])){
  // normal page render

The above code will help you to identify the client browser. The second method is also simple, here is code

if($_SESSION['JSexe']){     //3rd check js
    if($_COOKIE['JS'])  setcookie('JS','JS',time()-1);//check on every page load
    else            header('Location: js.html');
}               //2nd so far it's been server-side scripting. Client-side scripting must be executed once to set second cookie.
                //Without JSexe, user with cookies and js enabled would be sent to js.html the first page load.
elseif($_COOKIE['PHP'])     $_SESSION['JSexe'] = true;
else{               //1st check cookies
    if($_GET['cookie']) header('Location: cookies.html');
                header('Location: '.$_SERVER['REQUEST_URI'].'?cookie=1');

Any bugs and doubts, drop your comment below.


About Varadharaj V

The founder of Kvcodes, Varadharaj V is an ERP Analyst and a Web developer specializing in WordPress(WP), WP Theme development, WP Plugin development, Frontaccounting(FA), Sales, Purchases, Inventory, Ledgers, Payroll & HRM, CRM, FA Core Customization, PHP and Data Analyst. Database Management Advance Level

Comment Below

Your email address will not be published. Required fields are marked *


Current ye@r *