Set session variable using javascript
<script type="text/javascript"> function checkQuery() { var val = form1.proDown.options[form1.proDown.options.selectedIndex].value; var txt = form1.proDown.options[form1.proDown.options.selectedIndex].text; //alert(val+' | '+txt); <?php $_SESSION['value1']= ?> = txt; <?php ; ?> } </script> Do I have this code and it does not work? Anyone has a solution to access the javascript variable in $ _SESSION [].
I think you should use xhr (Ajax) to store your data in php session. Below is a simple example of this
jQuery.ajax({ url: 'storesession.php', type: 'POST', data: { txt: txt, }, dataType : 'json', success: function(data, textStatus, xhr) { console.log(data); // do with data eg success message }, error: function(xhr, textStatus, errorThrown) { console.log(textStatus.reponseText); } }); storesession.php
$_SESSION['value1'] = $_POST['txt'];