Hello @kartik,
You can't set a server session variable directly from JS.
To do that you can make an AJAX call to a PHP script passing the value you want to set, and set it server side:
$('#editRole').on('show.bs.modal', function (e) {
$roleID = $(e.relatedTarget).attr('data-id');
//ajax call
$.ajax({
url: "set_session.php",
data: { role: $roleID }
});
});
set_session.php
//preliminary code
Session::put('roleID', $request->input('role') );
Hope this is helpful!
To know more about javascript, join comprehensive Java training course online.