Click here to Skip to main content
15,886,963 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
how to check session value null or not on a button click ? if session value is null then i need to show an alert message to select that particular value for the session. i want to do it using jquery. how can i do it ? using jquery i can show the the alert message but can not check the sessio value.

What I have tried:

JavaScript
$( ".checkout-button" ).click(function() {
        alert( "alert message" );
    });
Posted
Updated 21-Nov-16 8:53am
v3

1 solution

Suppose that you want to check name in userdata then make a page with name checksession.php with this code


PHP
<?php echo isset($_SESSION['some_name']);        ?>



then in jquery put this code inside click handler

     $( ".checkout-button" ).click(function() {
        $.get( "checksession.php", function( data ) {
          if(data==="TRUE")
           {
              //session found stuff
              alert('session exist');
           }
          else{
              //session not found stuff
              alert('session not exist');
          }

        });
}
 
Share this answer
 
v6

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900