-1

This is my code I am Assigning a value to PHP but Not able to get in PHP SESSION. Tried all possible way. Also, I tried to set SESSION from javascript not get values.

 var designation = $("#Designation").val();
              <?php $_SESSION['lclDesignation'] = "<script type='text/javascrip'>alert(desi);</script>"?>
Keri
  • 47
  • 9

1 Answers1

2

It's not possible to directly assign session value. using AJAX to assign the session value. Please review below code

var designation = $("#Designation").val();
$.ajax({
  url: "session.php",
   type: "POST",
   data : {'designation' : designation },
  success: function(html){

  }
});

Then create the session.php file paste the below code

session.php

session_start();

$_SESSION['lclDesignation']=$_POST['designation'];
VRB
  • 186
  • 14