javascript - Starting a PHP session on a jQuery function event -


i've got simple jquery function , @ point (let's on button click) i'd start php session.

    $(document).ready(function() {         $(".loginpopupbutton").click(function(){             //here i'd need way trigger session.         });     }); 

i assume starting session php can done changing php variable. example - php can like:

    <?php         $testvar = null;         if(isset($testvar)){             session_start()             $_session['sessionstarted'] = $testvar;         }      ?> 

is there way such session started?

   <?php     session_start();      if(isset($_get['login'])) {          if(isset($_session['sessionstarted'])) {             echo 'session set';         } else {             $_session['sessionstarted'] = $testvar;         }     }     ?> 

and client-side:

$(document).ready(function() {     $(".loginpopupbutton").click(function(){         //code redirect index.php?login=true or make ajax call, doesnt matter     }); }); 

then can add php checks, if session exists, not echo loginpopupbutton , on :)


Comments